Please help me to convert the following sas code to macros
1, proc gchart data=HTWT ;
vbar gender/sumvar=weight;
Title" Average weigt by Gender";
2, proc plot data=HTWT;
Title"Scatter plot";
plot &height*&weight;
run;
The macro should have parameters, here you have dsetin, height and weight as positional parameters. if in these parameters if you pass the dataset name and variable names you will get graph
%macro plot(dsetin,height,weight);
proc gplot data=&dsetin;
Title"Scatter plot";
plot &height*&weight;
run;
%mend;
%plot(HTWT,height,weight);
similarly you could try for the other
The macro should have parameters, here you have dsetin, height and weight as positional parameters. if in these parameters if you pass the dataset name and variable names you will get graph
%macro plot(dsetin,height,weight);
proc gplot data=&dsetin;
Title"Scatter plot";
plot &height*&weight;
run;
%mend;
%plot(HTWT,height,weight);
similarly you could try for the other
Proc GCHART and PLOT are old. If you're developing actual working code I would recommend a switch to SGPLOT.
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!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.