Write and run SAS programs in your web browser

MACRO

Accepted Solution Solved
Reply
Occasional Contributor NVN
Occasional Contributor
Posts: 14
Accepted Solution

MACRO

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;

 

 


Accepted Solutions
Solution
‎06-03-2017 04:53 AM
Trusted Advisor
Posts: 1,137

Re: MACRO

[ Edited ]

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


All Replies
Solution
‎06-03-2017 04:53 AM
Trusted Advisor
Posts: 1,137

Re: MACRO

[ Edited ]

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
Super User
Posts: 18,570

Re: MACRO

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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