MACRO

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

MACRO

Please help me to do the following problem.

 

Revenue informations are avilabe for different years from 2005 to 2009 with the variable "Revenue". write the sas macro which 

will applay "Means and univariable " procedure on each year for revenue avilabe.


Accepted Solutions
Solution
‎06-03-2017 07:43 AM
Trusted Advisor
Posts: 1,147

Re: MACRO

[ Edited ]

without sample data it is not possible to present the accurate code. This is an untested code

 

It creates year wise separate dataset for means and univariate

 

 

%macro test(dsetin,year,revenue);
%do i=2005 %to 2009;
proc means data=&dsetin;
where &year=&i;
var &revenue;
output out=means_&i. mean=;
run;

proc univariate data=&dsetin;
where &year=&i;
var &revenue;
output out=univariate_&i. mean=;
run;
%end;
%mend;

 

 

 

Thanks,
Jag

View solution in original post


All Replies
Solution
‎06-03-2017 07:43 AM
Trusted Advisor
Posts: 1,147

Re: MACRO

[ Edited ]

without sample data it is not possible to present the accurate code. This is an untested code

 

It creates year wise separate dataset for means and univariate

 

 

%macro test(dsetin,year,revenue);
%do i=2005 %to 2009;
proc means data=&dsetin;
where &year=&i;
var &revenue;
output out=means_&i. mean=;
run;

proc univariate data=&dsetin;
where &year=&i;
var &revenue;
output out=univariate_&i. mean=;
run;
%end;
%mend;

 

 

 

Thanks,
Jag
Occasional Contributor NVN
Occasional Contributor
Posts: 14

MACRO

Please help me to do the following problem.

 

Revenue informations are avilabe for different years from 2005 to 2009 with the variable "Revenue". write the sas macro which 

will applay "Means and univariable " procedure on each year for revenue avilabe.

 

Trusted Advisor
Posts: 1,147

Re: MACRO

Please do not post the same question
Thanks,
Jag
Super User
Posts: 10,270

Re: MACRO

Posted in reply to Jagadishkatam

I merged the two identical questions.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 258 views
  • 0 likes
  • 3 in conversation