BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NVN
Fluorite | Level 6 NVN
Fluorite | Level 6

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

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

Thanks,
Jag

View solution in original post

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

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

Thanks,
Jag
Reeza
Super User

Proc GCHART and PLOT are old. If you're developing actual working code I would recommend a switch to SGPLOT. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 969 views
  • 0 likes
  • 3 in conversation