Programming the statistical procedures from SAS

Dealing with missing obs - proc reg and proc calis

Reply
N/A
Posts: 1

Dealing with missing obs - proc reg and proc calis

Hi,

I have a dataset with lots of variables (20+) and not many observations (countries by each geographic locations).

There are many missing values for each observation.

I want to do two things:

1. Using  proc reg: Run OLS with only variables that have common non-missing values.

For example, if I have a dataset looks like below:

var1  var2 var3 var4 var5

1       .      3      .     4

2       .       .      3    5

How can I set up commands such that it runs regression with only var1 and var5 (that have values in common). My understanding is that proc reg drops all observations that have missing values.

2. Using proc calis: FIML

I read an article :Making Use of Incomplete Observations in the Analysis of Structural Equation Models: The CALIS Procedure’s Full Information Maximum Likelihood Method in

SAS/STAT 9.3 by

Yiu-Fai Yung and Wei Zhang, SAS Institute Inc., Cary NC

I have SAS 9.2 and it seems this FIML in proc CALIS procedure is not available for 9.2. I get an error message like below:

proc calis data=WB_FAO2_sub1 method=FIML;     

ERROR 22-322: Syntax error, expecting one of the following: ADF, D, DWLS, G, GLS, LS, LSADF, LSD,

LSDWLS, LSG, LSGLS, LSM, LSMAX, LSML, LSW, LSWLS, M, MAX, ML, NONE, U, ULS, W, WLS.

ERROR 76-322: Syntax error, statement will be ignored.

How can I run FIML in SAS 9.2?

Please help me out on this. Thanks a lot!

                                                                 

Super User
Posts: 5,241

Dealing with missing obs - proc reg and proc calis

Subong,

I can help with question 1, but not question 2.

Finding which variables are always nonmissing is easy.  Here's one approach.

proc means data=mydata nmiss maxdec=0;

   var _numeric_;

run;

This doesn't automate the process at all, but it's not clear from your post whether you need to do that and whether your familiarity with macro language would be sufficient for that task.  In theory, it would be possible for PROC MEANS to create an output data set, and for subsequent processing to capture the names of the variables that have NMISS = 0.  That "subsequent processing" could create a macro variable holding the list of variable names and pass that list to PROC REG.  Is that the path that you need to travel, or is the simple version good enough?

Good luck.

Super Contributor
Posts: 1,636

Re: Dealing with missing obs - proc reg and proc calis

Hi,

You can use the code below to get rid of all the variables with missing value.

data one;

input var1-var5;

cards;

1 . 3 . 4

2 . . 3 5

;

options missing= ' ';

proc transpose data=one out=two;

var _all_;

run;

options missing='.';

data _null_;

length keep $500;

if 0 then set one nobs=nvar;

do until (done);

  set two end=done;

  if n(of colSmiley Happy eq nvar then keep=catx(' ',keep,_name_);

end;

call symputx('keep',keep);

run;

data want;

set one (keep=&keep);

run;

proc print data=want;run;

Obs    var1    var5

1       1       4

2       2       5


Linlin

Ask a Question
Discussion stats
  • 2 replies
  • 214 views
  • 0 likes
  • 3 in conversation