BookmarkSubscribeRSS Feed
coug914
Calcite | Level 5

I'm running a corr function in iml, e.g.,

proc iml;

  use want_ret;

  read all var _NUM_ into x[colname=permno];

  close want_ret;

  corr=corr(x);

  print corr;

quit; run;

Because my data has some missing value I get an execution error - "Invalid argument or operand; contains missing value."

I found this page which seems to suggest that I should be able to compute it with missing values: http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/default/viewer.htm#imlug_langref_sect05...

I thought the syntax would be corr(x,Pearson,pairwise); but that doesn't seem to work either. Any ideas? I'd like the correlation even though I'm missing just a few observations in the time series.

Thanks,

Rick

3 REPLIES 3
Rick_SAS
SAS Super FREQ

The CORR function supports missing values:

proc iml;
use sashelp.class;
read all var _NUM_ into X;
X[{1 7 19 32}]=.;
c = corr(x);
print c;
print (countmiss(X,"col"));

In fact, you can have all missing values and hte CORR function still doesn't return an error:


X = j(10,3,.);
c = corr(x);
print c;

This assumes that you are running SAS/IML 9.22 or later. Please copy/paste the EXACT contents of the SAS log.

By the way, if you use optional arguments, be sure to enclose them in quotes

corr(x,"Pearson","pairwise");

as specified in the doc.

coug914
Calcite | Level 5

I appear to be running sas 9.2. If I hit about sas it says SAS 9.2 TS Level 2M2, X64_VSPRO platform. Is that the issue?

thanks,

Rick

Tom
Super User Tom
Super User

I think that TS2M3 is the stealth SAS/Stat upgrade to 9.22.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 3 replies
  • 1162 views
  • 0 likes
  • 3 in conversation