- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
i want to creat a macro variable to store (2,4,15,16) in it, How to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Two questions:
- where is the list coming from (fixed constant, dataset, ....)?
- how should it be used (determines the format of the list)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
"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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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