SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
kjohnsonm
Lapis Lazuli | Level 10

Hello does anyone know if I can set proc contents to default to 

 

set proc contents default 'order=varnum'?

 

I think my is set to collate.  

I mean I do not want to have to type out

proc contents data={myfile} order=varnum;

run;

 

but 

proc contents data={myfile};

run;

or

proc contents;run;

...is fine when I use it 10 -20 times a day and yes I know about abbreviations.

-TIA KJ

 

 

 

3 REPLIES 3
mkeintz
PROC Star

Write a macro, such as   CNTNTS below:

 

%macro cntnts (data=_last_);
    proc contents data=&data  varnum;
    run;
%mend;

Then you can type:

 

%cntnts (data=mylib.mydata);

to get what you want for dataset mylib.mydata.

 

And you get the bonus of just typing:

 

%cntnts;

 

to report on the data set most recently created in your current sas session.  That's why I put in the automatic variable _LAST_ as the default "data=" option in the macro definition.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Patrick
Opal | Level 21

You can't change this default. Happy typing!

Astounding
PROC Star

You'll have to check this, to see whether it is still supported.  It might let you get away with typing one extra letter.

 

There used to be statement style macros available as part of the software.  That means you could invoke a macro just by typing the name of the macro without a percent sign:

 

http://www.sascommunity.org/sugi/SUGI84/Sugi-84-179%20Henderson%20Kuhn.pdf

 

So you could create your own statement-style macro using:

 

%macro contentss / stmt;

   contents order=varnum

%mend contentss;

 

Then in the body of your program, you would just have to type an extra "s":

 

proc contentss data=mydataset;

run;

 

SAS would automatically replace "contentss" with "contents order=varnum".

 

If that would be a viable solution for you, give it a try and see if it is still supported.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2324 views
  • 4 likes
  • 4 in conversation