BookmarkSubscribeRSS Feed
corella
Calcite | Level 5
Text was removed as it appeares cut after posting Message was edited by: corella
1 REPLY 1
Cynthia_sas
SAS Super FREQ
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]

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 949 views
  • 0 likes
  • 2 in conversation