data _null_;
set sashelp.class end = last;
call symput ('sname' || trim(left(_n_)) , name);
if last then call symput ('var_count' , _n_);
run;
%macro newvar;
data output;
set sashelp.class;
%do = 1 %to &var_count;
&&sname&i = (name = "&&sname&i");
%end;
%newvar;
%mend;
You can achieve something similar without macro coding:
data class;
set sashelp.class;
value = 1;
run;
proc transpose data=class out=want (drop=_name_);
by name age sex weight height;
var value;
id name;
run;
It is the same as
data have;
set sashelp.class;
dummy=1;
run;
proc logistic data=have outdesign=want(drop=intercept dummy) outdesignonly;
class name/param=glm;
model dummy=name;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.