BookmarkSubscribeRSS Feed
max00d
Obsidian | Level 7
Hi - sorry very new to SAS & EG - I am trying to create a list of dates that I can then use further on as parameters in a drop down box. I know how to do the latter but I cant figure out how to create a variable with a list of dates.

So for example using:

data test;
date_today = today();
CurMonth = month (date_today) ;
CurYear = year (date_today) ;
lstMonth = MDY(CurMonth-1, 1, Curyear) ;
NxtMonth = MDY(CurMonth+1, 1, Curyear) ;
format date_today mmddyy10. ;
format lstmonth mmddyy10. ;
format NxtMonth mmddyy10. ;
run;

So my question is that given I have established a list of dates, CurMonth, lstmonth and Nxtmnth - how do I put these into a data table under a variable name 'Mnth_List'
1 REPLY 1
RichardH_sas
SAS Employee
So, it sounds like you're good to go on setting up the parameter the way you want. I think you're asking how to transform a data set with one row and five columns into a data set with five rows and one column. Is that correct?

CurMonth CurYear lstMonth NxtMonth
5 2010 04/01/2010 06/01/2010

If you want to get five rows and one column (well, two columns really, but just one column with the values in question), I would use a stack columns task. Drag all the variables into the Columns to Stack role. The only problem with this is it will not preserve the formatting on the dates. If you wanted to go that route, I'd make all the columns character in the code you supplied via PUT functions (example: date_today=put(today(),mmddyy10.) ). Note that the Stack Columns task does require all character or all numeric columns in what it can stack.

FYI, if you're using EG 4.2 you should check out the Date and Date Range prompt types... those may have the functionality you're after here with Today, Current Day of Next Month, etc.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3503 views
  • 0 likes
  • 2 in conversation