## Simplest Proc Corr Code

Solved
Frequent Contributor
Posts: 115

# Simplest Proc Corr Code

proc corr data = L_P1.UWR_10YrData plots(maxpoints = none) = matrix(nvar = all);

var D_DELQ_DEFU_INDN D_DELQ_NATL_PCTL D_DELQ_SCR D_FAIL_DEFU_INDN D_FAIL_NATL_PCTL D_FAIL_SCR;

run;

How may I simplify my code so that it does not request a plot?

While on this topic, is there also a way to request all _numeric_ vars that begin with a prefix of D_?

Thank you.

Accepted Solutions
Solution
‎01-23-2015 11:42 AM
Posts: 3,852

## Re: Simplest Proc Corr Code

Don't you mean FROM DICTIONARY.COLUMNS not FROM L_P1.UWR_10YRDATA

All Replies
Posts: 1,270

## Re: Simplest Proc Corr Code

proc corr data = L_P1.UWR_10YrData plots(maxpoints = none) = matrix(nvar = all);

var D_:;

run;

Posts: 5,535

## Re: Simplest Proc Corr Code

First question: PLOTS=NONE;

Second question: if all variables beginning with prefix D_ are numeric, use VAR D_:;

PG

PG
Super User
Posts: 10,784

## Re: Simplest Proc Corr Code

Not sure if it could work.

ods _all_ close;

ods graphics off;

proc corr

PROC Star
Posts: 8,164

## Re: Simplest Proc Corr Code

You haven't marked your question as correct yet, thus I presume you either forgot or are waiting for more possibilities. Here is one more possibility:

proc sql noprint;

select name

into :vars separated by ' '

from sashelp.vcolumn

where libname='L_P1' and

memname='UWR_10YRDATA' and

type='num'

;

quit;

proc corr data = L_P1.UWR_10YrData;

var &vars.;

run;

Frequent Contributor
Posts: 115

## Re: Simplest Proc Corr Code

I am intrigued by this possibility - and I apologize for taking so long to respond.

First, the line from sashelp.vcolumn. It seems be a little redundant with the where libname... stuff that follows identifies the library and name of the data file. It seems to be redundant with the where statement that precedes it.

So I changed the line saying from sashelp.vocolumn and I receive multiple errors:

I am pretty sure that is it is pretty simple. And again I am very intrigued by how this may keep things simple. My entire block of code follows:

libname L_P1 "\\SAS01\sasusers\Shared\PredictiveModeling";

proc sql noprint;

select name

into :vars separated by ' '

from L_P1.UWR_10YrData

where libname='L_P1' and

memname='UWR_10YrData' and

type='num';

quit;

proc corr data = L_P1.UWR_10YrData;

var &vars.;

run;

libname L_P1 clear;

Thank you.

PROC Star
Posts: 8,164

## Re: Simplest Proc Corr Code

The libname and filename (memname) have to be in upper case. Just change the 'r' to be an 'R'

Frequent Contributor
Posts: 115

## Re: Simplest Proc Corr Code

Still not working:

proc sql noprint;

select name

into :vars separated by ' '

from L_P1.UWR_10YRDATA

where libname='L_P1' and

upcase(memname)='UWR_10YRDATA' and

type='num';

quit;

proc corr data = L_P1.UWR_10YRDATA;

var &vars.;

run;

I added an upcase function to memname to get it to work.

PROC Star
Posts: 8,164

## Re: Simplest Proc Corr Code

Can you post your log so we can see what isn't working?

Frequent Contributor
Posts: 115

## Re: Simplest Proc Corr Code

Sure. The actual log follows. Thanks.

1                                                          The SAS System                             10:27 Friday, January 23, 2015

1          %_eg_hidenotesandsource;
5          %_eg_hidenotesandsource;
28
29         libname L_P1 "\\SAS01\sasusers\Shared\PredictiveModeling";
NOTE: Libref L_P1 was successfully assigned as follows:
Engine:        V9
Physical Name: \\SAS01\sasusers\Shared\PredictiveModeling
30
31         proc sql noprint;
32           select name
33             into :vars separated by ' '
34               from L_P1.UWR_10YRDATA
35                 where libname='L_P1' and
36                       upcase(memname)='UWR_10YRDATA' and
38                       type='num';
ERROR: The following columns were not found in the contributing tables: libname, memname, name, type.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
39         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time           0.00 seconds
cpu time            0.01 seconds

40

41         proc corr data = L_P1.UWR_10YRDATA;
42           var &vars.;
_
22
200
WARNING: Apparent symbolic reference VARS not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.
ERROR 200-322: The symbol is not recognized and will be ignored.
44         run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE CORR used (Total process time):
real time           0.00 seconds
cpu time            0.00 seconds

45
46         libname L_P1 clear;
NOTE: Libref L_P1 has been deassigned.
47
48
49         %_eg_hidenotesandsource;
61
62
63         %_eg_hidenotesandsource;
66

Solution
‎01-23-2015 11:42 AM
Posts: 3,852

## Re: Simplest Proc Corr Code

Don't you mean FROM DICTIONARY.COLUMNS not FROM L_P1.UWR_10YRDATA

Frequent Contributor
Posts: 115