i want to creat a macro variable to store (2,4,15,16) in it, How to do this?
Two questions:
- where is the list coming from (fixed constant, dataset, ....)?
- how should it be used (determines the format of the list)?
create a macro variable to store fixed constant integer so that i can pass that in my program.
like for example %Let a= (4, 5, 6) but this is not working
"this is not working" is not helpful.
You need to be much more specific, ie by posting the relevant piece of code and the log, and the data as it came out and as you wanted it to be.
Why do you say it's not working? It's easy to check. Assuming you added a semicolon:
%let a = (4, 5, 6);
%put **&a**;
What's actually happening is that the statement works, but you don't know what to do with the result. It is highly likely that you should heed the suggestion about keeping data in data sets instead of macro variables. If you show what you are trying to accomplish, you are pretty sure to get some helpful suggestions.
Why? Why not put that list of "data" items in a "data"set that is what "datasets" are for storing data. Macro language is not a replacement for Base SAS - it is a text generation tool.
Hi:
Consider this program (with different numbers so I could use it with SASHELP.CLASS):
title; footnote;
%let a=(14,15,16);
%put -----> macro variable a is: &a;
options mprint symbolgen;
proc print data=sashelp.class;
title "Looking for Ages &a";
where age in &a;
run;
data new;
x = sum&a;
run;
proc print data=new;
title "adding up values &a in parentheses with sum function";
run;
title;
Illustrates 2 completely different uses of &a in 2 different steps. So what the OP wants and what the data looks like and the reason for having the numbers in a macro variable need to be explained so that everybody understands WHAT the OP is trying to accomplish.
The above program generates this in the log and output:
But without a context for the question, it's hard to know which generated code is the desired aim.
cynthia
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.