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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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