SAS Notes

Compiled by : Wilson Suraweera @ CGHR
Contents
Random Numbers in SAS
Data Sub-setting
Method  for Select a Random Sample
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
External Resources
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

 

         

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