BookmarkSubscribeRSS Feed
ballardw
Super User

Is your current date variable character or a SAS date valued numeric with a format to display values in the 10December2019 format?

 

If you have a SAS date value then you can use a format on the variable to create groups.

 

The SASHELP.STOCKS data set that you likely have available has date for the daily Stock price information like open, high , low and close.
Since the date is a SAS date value using a DATE7. format to do a monthly summary you could use a YYMM or YYMON format to show a summary for a month.

 

Proc means data=sashelp.stocks min mean max;
   class stock date;
   format date yymon7.;
   var open close high low;
run;

In SAS you will find that if you date to time values that you want to make sure your variable is the appropriate date, time or datetime value so you can do manipulation and display with the SAS functions, supplied formats or even create your own display formats.

 

The groups created by a format will generally work for analysis, reporting or graphing.

So by changing the format in the above Proc Means code from yymon7 to yyq. I could get a calendar quarterly summary, or using the YEAR format an annual summary.

AK100
Pyrite | Level 9
I did not understand this method, the method of Kurt seemed a bit more easier. But thank you anyway, appreciate your help.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 16 replies
  • 1051 views
  • 2 likes
  • 4 in conversation