## MACRO

Solved
Occasional Contributor
Posts: 14

# MACRO

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
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

All Replies
Solution
‎06-03-2017 07:43 AM
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
Posts: 14

## MACRO

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.

Posts: 1,147

## Re: MACRO

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

## Re: MACRO

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.