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

Hi,

I have two datasets. One has only yearly observations for month 7. Another one has monthly frequency for each year year. 

I need to rearrange this code for the  dataset where with monthly observations and find a monthly  holding period of 30 days. My monthly dataset starts in january 1926 and ends in march 2012.

 

This is the code for the dataset for annual observations

/*I'm creating two variables. These are date variables.
one will store July 1st of the same year
one will store 30/ of next year
this is the holding period.
This is useful because I only need to get from CRSP the return for this period*/

 

data sample_stocks;
set sample5;
Beginning_date=mdy(07,01,year);
End_date=mdy(06,30,year+1);
format End_date date9.;
format Beginning_date date9.;
drop Mkcap sum_Mkcap number_stocks;
run;

Do you have any tips to modify this code? 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

If all you want is the end date from the next month:

 

end_date = intnx("month", date, 1, "end");

PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

Please provide a small meaningful sample of both input datasets and of the corresponding expected output data table.

PG
Lukito
Calcite | Level 5

This is a sample of my input table:

Input DataSetInput DataSet

This is what i would like have in output:

Output DataSetOutput DataSet

The Beginning_year should be equal to my date, because it represent the start point of the my Holding period.

The End_Date should be equal to the last day of the next month (ex. in the first row should be equal to 28FEB1926), because my holding period is one month.

 

I hope this suggestions, will be clear.

Thanks for your help.

PGStats
Opal | Level 21

If all you want is the end date from the next month:

 

end_date = intnx("month", date, 1, "end");

PG

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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