Hi All,
Following is my dataset
data have;
input var1 $20;
cards;
robert
is
my
boss
;
run;
Now , i want to have one single macro variable which would resolve to robert is my boss
In short, I want to concatenate all obseervations in one single macro. Catch is not to use Proc sql. I know below single statement would have solved my purpose, but I have to use datastep and not proc sql.
proc sql; select var1 into :macvar1 separated by " " from have;
Any help would be highly appreciated
Why not SQL?
One should chose whatever tool seems best/easiest for each task...
Anyway, concatenate your vaues into a retained value, and the call symput when the data step reaches the last record/EOF (I guess that your real life data is not provided in datalines)
Agree Linus, but that's what my client's requirement is. They are insisting on data steps as they previously had experienced that having mixed macro variables (few from datastep and few from proc sql) tend to create problems in their environment. Anyways, can you please elaborate on your approach (EOF and retain). I tried using that as well , however it could not work.
Thanks keith... that worked .. I had used retain earlier in sum but never thought it could be applied to char variables as well
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.