Help using Base SAS procedures

Simplest Proc Corr Code

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 115
Accepted Solution

Simplest Proc Corr Code

Please view the following 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;

with BLEND_GROSS_LOAD;

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
Respected Advisor
Posts: 3,799

Re: Simplest Proc Corr Code

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

View solution in original post


All Replies
Trusted Advisor
Posts: 1,228

Re: Simplest Proc Corr Code

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

  var D_:;

with BLEND_GROSS_LOAD;

run;

Respected Advisor
Posts: 4,932

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,044

Re: Simplest Proc Corr Code

Not sure if it could work.

ods _all_ close;

ods graphics off;

proc corr

PROC Star
Posts: 7,491

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

              upcase(name) ne 'BLEND_GROSS_LOAD' and

              type='num'

  ;

quit;

proc corr data = L_P1.UWR_10YrData;

  var &vars.;

  with BLEND_GROSS_LOAD;

run;

Frequent Contributor
Posts: 115

Re: Simplest Proc Corr Code

Capture.JPG

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

              upcase(name) ne 'BLEND_GROSS_LOAD' and

              type='num';

quit;

proc corr data = L_P1.UWR_10YrData;

  var &vars.;

  with BLEND_GROSS_LOAD;

run;

libname L_P1 clear;

Thank you.

PROC Star
Posts: 7,491

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

              upcase(name) ne 'BLEND_GROSS_LOAD' and

              type='num';

quit;

proc corr data = L_P1.UWR_10YRDATA;

  var &vars.;

  with BLEND_GROSS_LOAD;

run;

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

PROC Star
Posts: 7,491

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.

Capture.JPG

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
37                       upcase(name) ne 'BLEND_GROSS_LOAD' 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.
43           with BLEND_GROSS_LOAD;
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
Respected Advisor
Posts: 3,799

Re: Simplest Proc Corr Code

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

Frequent Contributor
Posts: 115

Re: Simplest Proc Corr Code

Posted in reply to data_null__

Works perfectly now. Thank you very much.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 11 replies
  • 511 views
  • 3 likes
  • 6 in conversation