DATA Step, Macro, Functions and more

variable list

Reply
Contributor
Posts: 73

variable list

Hello

I would like to define a list like this
var Jan_10 Feb_10 Mar_10 Apr_10 May_10 Jun_10 Jul_10;

then call it from any program when needed, how can i do this simply?

Fred
Regular Contributor
Posts: 165

Re: variable list

Hi,

Without knowing more about what exactly you want to accomplish you could just put the variables in a macro variable to be used in var statements across procs. Something like

%let vars=Jan_10 Feb_10 Mar_10 Apr_10 May_10 Jun_10 Jul_10;

then in your program, lets say in proc print, you would use

proc print data=dsn;
var &vars;
run;
Contributor
Posts: 73

Re: variable list

Thanks RickM, i had attempted this myself and it did not work but it did this time.

Crazy but often it does not work until you show someone, then it does and makes you look like a clown.

Thanks again

Fred
Super Contributor
Super Contributor
Posts: 3,174

Re: variable list

Investigate using the old-style MACRO statement or MACRO variable for simple context substitution. Samples are listed below:

%LET XXXX = %QUOTE( * this is a comment; );

MACRO _YYYY
* this is also a comment;
%

The first example is referenced by &XXXX in your program.

The second example is referenced by the character string _YYYY -- in this case, the SAS code parser sees the MACRO statement declaration and then will make the substitution in its place.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 3 replies
  • 129 views
  • 0 likes
  • 3 in conversation