SAS Notes

Compiled by : Wilson Suraweera @ CGHR
Contents
Random Numbers in SAS
Data Sub-setting
Selection  of  two Random Samples
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
Text analysis - an Epedomiological Case Study by WS - SAS Institute HUG -01 April2011
Reading XPORT transport file into SAS 
External Resources
SAS Knowledge Base - Glossary of SAS Proceedures from SAS.com
Macro Seminar - UCLA
Logistic regression
          Some Interesting SAS SQL Examples
SAS Dinosaur - Old and New way of SAS progrming
Paul Dicman's Web Page for SAS- This little old discusses SAS 8, but useful
Global Statements Dictionary - Alphabatical listing and Description of SAS Key words
SAS Study Blog
         

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