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 values replacement with Means of the respective Variables

/*********************************************************************/;

/* This macro created for */;

/* Missing values replacement with Means of the respective Variables */;

%macro replace_missing(dataset);

      proc means data=&dataset mean ; ;

            output out=t (drop=_type_ _freq_) mean=/autoname;

    run;

      proc transpose data=t out=tr;

      run;

data _null_;

      set Tr end=last ;

      call symput('mean'||left(_n_),col1);

      if last then call symput('maxi', _n_);

            /* x=left(_N_) */;

            /* put _N_ maxi last x ; */;

run;

data &dataset;

      set &dataset;

      array Ages(*) _numeric_;

            %do n=1 %to &maxi;

                  if Ages(&n)=. then Ages(&n)= &&mean&n;

            %end;

run;

%mend;

%replace_missing(age_f);

run;

 

Back to Top