BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Saba1
Quartz | Level 8

Hi

 

I have 740 firms and I want to attach dates of trading days from June 8th 2020 till July 17th 2020 with these firms. Hence, each firm needs to have a time series of daily dates (Panel data). I want to create a list of dates for these trading days in mmddyy10. format. Is there any SAS code which can help me in this regard? Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

I think you might be asking about an earlier part of the process ... how to create the list of dates.  If that's the case, you need to know the holidays in that time period.  Assuming that the only holiday is the fourth of July, you could use:

 

data trading_days;
do date = '08jun2020'd to '17jul2020'd;
   if 1 < weekday(date) < 7 and date ne '04jul2020'd then output;
end;
format date mmddyy10.;
run;

You will need to check whether there were any other dates in that timeframe, and whether the fourth of July was actually celebrated on July 4th rather than a nearby date.

 

The earlier post gives you ways to combine this list of dates with your set of 740 firms.

View solution in original post

3 REPLIES 3
smantha
Lapis Lazuli | Level 10
You can use three approaches
1. Use a do loop in a data step and output each record
Do start to end;
If trading day out put
End do;

2. If you have a separate data set with dates then a sql join will help. Do not specify a key to join
Proc sql;
Create table want
As select a. Id, b.Date
From a, b;
Quit;
3. You can use a combination of proc expand and proc calendar.
Astounding
PROC Star

I think you might be asking about an earlier part of the process ... how to create the list of dates.  If that's the case, you need to know the holidays in that time period.  Assuming that the only holiday is the fourth of July, you could use:

 

data trading_days;
do date = '08jun2020'd to '17jul2020'd;
   if 1 < weekday(date) < 7 and date ne '04jul2020'd then output;
end;
format date mmddyy10.;
run;

You will need to check whether there were any other dates in that timeframe, and whether the fourth of July was actually celebrated on July 4th rather than a nearby date.

 

The earlier post gives you ways to combine this list of dates with your set of 740 firms.

Saba1
Quartz | Level 8
Many Thanks.

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!
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
  • 3 replies
  • 1022 views
  • 5 likes
  • 3 in conversation