Hi all,
I have been trying to create a calendar-style report - when I've seen examples using proc calendar, the output is very 80s like, using only ANSI characters. But there must be a way to create a calendar report with a properly formatted grid and more up-to-date style, right? I've found code that just creates the calendar, but don't know how to incorporate the dataset into this, as I am still pretty new to SAS:
Data Calendar;
Array Days(7) Sun Mon Tue Wed Thu Fri Sat (7*.);
Format Sun Mon Tue Wed Thu Fri Sat Date Date5.;
Drop Date X;
Do Date = '01Jan2013'D to '31Mar2013'D by 1;
Days(WeekDay(Date)) = Date;
/*Quarter = Put(Date,YYQ6.);*/
If WeekDay(Date) = 7 Then
Do; Output;
Do X=1 to Dim(Days); Days(X)=.; End;
End;
If Month(Date) NE Month(Date+1)Then
Do; Output;
Do X=1 to Dim(Days); Days(X)=.; End;
End;
End;
If NMiss(Sun,Mon,Tue,Wed,Thu,Fri,Sat) < 7 Then Output;
Proc Print;
Title1 'Calendar Data Step Output';
Run;
This displays what's in the attachment. Would I be able to do this using PROC Tabulate (or similar) and use NOOBS to hide the observation numbers?
You don't need other proc.
proc print has an option to suppress obs column.
proc print data=sashelp.class noobs;
run;
Ksharp
There are a lot of functions to generate month, qtr, date, dow etc from an actual date value.
Try playing with this to see if you can make PROC REPORT create a nice calendar.
proc format ;
value dayname
1='Sunday'
2='Monday'
3='Tuesday'
4='Wednesday'
5='Thursday'
6='Friday'
7='Saturday'
;
run;
data calendar ;
do date= '01JAN2013'd to '31DEC2013'D ;
year= year(date);
qtr = qtr(date);
month = month(date);
day = day(date);
week = week(date);
dow = weekday(date);
monname=put(date,monname.);
downame=put(date,downame.);
output;
end;
run;
proc report nofs ;
column year qtr month monname week dow,day ;
define year / group order=internal noprint ;
define qtr / group order=internal noprint ;
define month / group order=internal noprint ;
define monname / group order=internal noprint ;
define week / group order=internal noprint ;
define dow / across order=internal format=dayname. ' ';
define day / ' ';
compute before monname ;
x=length(monname);
line @1 monname $varying20. x ' ' year 4. ;
endcomp ;
break after qtr / page;
run;
I like @Tom's calander program. I wondered if it could be done with aliases and formats. I got close. I had to make diplicates of DATE for some and could not figure how to make across work with a formatted value of date.
If only the Across header could be repeated at the break on month.
Hi Tom and Data Null,
These are really great. The one thing is, if I have a dataset that I can join by date, how can I plunk some data into these calendars along with the date number? Is this a quick and easy thing or is it better to transpose the data itself and try to fit it into a calendar?
Thanks a bunch guys,
Tarun
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.