Intialize multivariables in one let

Reply
Contributor
Posts: 39

Intialize multivariables in one let

Hello,

Is there any way to intialize multivariable in one let statement?

I used below code

OPTIONS SYMBOLGEN;

%LET LAST =2 ST=1;

%PUT &LAST &ST.;


Output is

14         GOPTIONS ACCESSIBLE;

15         %let last =2 st=1;

16         %put &last &st.;

SYMBOLGEN:  Macro variable LAST resolves to 2 st=1

SYMBOLGEN:  Macro variable ST resolves to 1

2 st=1 1

So, Is there any way to intialize diffirent variables in same let statement.

Super User
Posts: 5,375

Re: Intialize multivariables in one let

No.

Why?

Data never sleeps
Contributor
Posts: 39

Re: Intialize multivariables in one let

I have 20 variables, that need to be declare. when i am declaring in one %let not working. Thought some body would know this.

Super User
Posts: 18,993

Re: Intialize multivariables in one let

It isn't possible. Depending on what you're trying to do may be other ways, but we don't know what you're trying to do.

Super User
Posts: 11,101

Re: Intialize multivariables in one let

You might be able to use a data set with the variable names the desired names of the macro variables and CALL SET.

Or CALL Execute.

How were you planning on using these variables?

Respected Advisor
Posts: 3,782

Re: Intialize multivariables in one let

Maybe you mean %LOCAL or %GLOBAL those statement can accept a list of macro variables.

%local last st;

To assign with %LET you can only do one at time.

Although there are other ways to assign.

You need to tell more about what you are trying to do.

SAS Employee
Posts: 19

Re: Intialize multivariables in one let

From the documentation, with links to the source:

Examples are included on the pages from the links specified above.

Kind regards, Jos

Regular Contributor
Posts: 226

Re: Intialize multivariables in one let

The only way you can do this is with a step;

either data _null_

or sql

Here is an example

%let last =2 st=1;

%put _user_;

data mvars;

mvar='last';value=2;

output;

mvar='st';value=1;

output;

mvar='st2';value=3;

output;

stop;

data _null_;

set mvars;

call symputx(mvar,value);

run;

%put _user_;

Ron Fehd  macro maven

Regular Contributor
Posts: 226

Re: Intialize multivariables in one let

I knew I had an answer to this Q

A: use a comma-delimited list of values

Here is the tool: parse sysparm

http://www.sascommunity.org/wiki/Parse_sysparm

Ron Fehd  macro maven

Ask a Question
Discussion stats
  • 8 replies
  • 527 views
  • 0 likes
  • 7 in conversation