Hi,
I am trying to drop rows of data that do not have 12/31 as their month and day. Does anyone know how to do this?
Example:
Historical CRSP PERMNO Link to COMPUSTAT Record | Data Date |
54594 | 5/31/18 |
54594 | 5/31/19 |
54594 | 5/31/20 |
21020 | 12/31/18 |
21020 | 12/31/19 |
21020 | 12/31/20 |
11499 | 12/31/18 |
DROP ALL DATES THAT ARE NOT 12/31.
Is your date variable numeric with a format like mmddyy8?
If so then you can get the Month from the date with the Month function, which returns the number of the month, and the Day function returns the number of the day in a month.
data want; set have; if month(datevar)=12 and day(datevar)=31; run;
If used this way, without a "then" subsets the data by keeping the values the condition is true for.
From what you showed I am not sure what the name of your variable is because "data date" is not a standard SAS variable name.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.