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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 690 views
  • 0 likes
  • 2 in conversation