DATA Step, Macro, Functions and more

Text was removed as it appears cut after posting

Reply
Occasional Contributor
Posts: 11

Text was removed as it appears cut after posting

Text was removed as it appeares cut after posting Message was edited by: corella
SAS Super FREQ
Posts: 8,743

Re: SAS beginner - how to write a macro that increments fiscal year by 1?

Hi:
When you use < and > symbols in your code, the forum posting software treats those characters as HTML tag delimiters. So you either have to use the alternate GT, GE, LT, LE operators in your code or you have to "protect" the < and > from being interpreted as HTML.

This previous forum posting explains how to post code and how to protect indention and < and > characters: http://support.sas.com/forums/thread.jspa?messageID=27609毙


Meanwhile, I believe this is the code you were trying to post. And, I think that if you read and work through the examples in this introduction to the SAS Macro facility, (http://www2.sas.com/proceedings/sugi28/056-28.pdf ) you will find one possible answer to your question. However, if you had a variable in your dataset that identified the fiscal year, you could use PROC MEANS with a CLASS statement or PROC REPORT or PROC TABULATE to give you a summary report. If you only need the OUTPUT dataset from PROC MEANS for PROC PRINT, there are other ways to accomplish a summary for each year.

cynthia
[pre]
*** Your posted code;

data fiscal_2001_2002;
set AllYears;
if (_date GE '01apr2001'd and _date LE '31mar2002'd);
run;

proc means data = fiscal_2001_2002 noprint;
output out = AllCorp_benefit_sum sum=total;
var benefit;
run;

proc print data=AllCorp_benefit_sum;
run;
[/pre]


Consider the following code which shows several alternate methods of creating summary reports -- with and without PROC MEANS.
[pre]

proc means data=sashelp.prdsale noprint;
output out=allqtr sum=total;
class year quarter;
var actual;
run;

ods listing close;
ods html file='c:\temp\compare_method.html'
style=sasweb;

proc print data=allqtr;
title '1) After Proc Means with CLASS';
title2 'Use _TYPE_ for separate summary information';
run;

proc report data=sashelp.prdsale nowd;
title '2) PROC REPORT';
column year quarter actual;
define year / group;
define quarter / group;
define actual / sum;
rbreak after / summarize;
compute after year;
line ' ';
endcomp;
run;

proc tabulate data=sashelp.prdsale;
title '3) PROC TABULATE';
var actual;
class year quarter;
table year*quarter all,
sum*actual;
keylabel sum=' ' all='Grand Total';
run;
ods html close;

[/pre]
Ask a Question
Discussion stats
  • 1 reply
  • 139 views
  • 0 likes
  • 2 in conversation