SAS Notes

Compiled by : Wilson Suraweera @ CGHR
Contents
Random Numbers in SAS
Data Sub-setting
Selection  of  two Random Samples
Identification and Separation of duplicate records in SAS dataset
Reshape Long list variable dataset to Wide list dataset
Missing values replacement with Means of the respective Variables
Logistic Regression with SAS
SAS made easy using Proc SQL
SAS PROC SQL procedure to access external ODBC data sources
SAS String Data Handling
SAS Missing value arithmetic's
          Update_a_Table_using_Another_Table_in_SAS
Text analysis - an Epidemiological Case Study by WS - SAS Institute HUG -01 April2011
 
External Resources
SAS Knowledge Base - Glossary of SAS Procedures from SAS.com
SAS resources from - UCLA
Logistic regression
          Survival Analysis : Usage of Proc LifeTest and Proc PHREG
SAS Dinosaur - Old and New way of SAS programming
Paul Dicman's Web Page for SAS- This little old discusses SAS 8, but useful
Global Statements Dictionary - Alphabetical listing and Description of SAS Key words
SAS Study Blog
SAS Canada - User Groups
         

Missing value arithmetic



/*******************************************************************/
	/* Rule : Numeric missing value arithmetic **********
	
	let X Non-missing value
		Y Missing value
		
	Then 	 X+Y is a Missing value
		 X-Y is a Missing value
		 X*Y is a Missing value
		 X/Y or Y/X is a Missing value
**************************************************/
data test;
	x=2; 
	y=.; 
	z=.m; /* x: Numeric value, y: Missing value, z: Special missing value */
	
/* eg. Addition, subtraction, multiplication, division */

	add1=x+y; subs1= x-y; mult1= x*y; div1= x/y;
	add2=x+z; subs2= x-z; mult2= x*z; div2= x/z;
	add3=y+z; subs3= y-z; mult3= y*z; div3= y/z; 
	
/* Results of all add, subs, mult and div values are become missing*/
/* Exception */ 
	add4=sum(x,y);   /* Interesting ! add4=2 is a non missing */
run;

/* to see the result */

	proc print data=test;
	run;
	
/* Result 

Obs x y z add1 subs1 mult1 div1 add2 subs2 mult2 div2 add3 subs3 mult3 div3 add4 
1   2 . M .    .     .     .    .    .     .     .    .    .     .     .    2 
*/

 

Learn More  : http://www.sfu.ca/sasdoc/sashtml/lrcon/z0989183.htm

Back to Top