BookmarkSubscribeRSS Feed
Subong
Calcite | Level 5

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!

                                                                 

2 REPLIES 2
Astounding
PROC Star

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.

Linlin
Lapis Lazuli | Level 10

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 col:) 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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1552 views
  • 0 likes
  • 3 in conversation