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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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