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

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 RecordData Date
545945/31/18
545945/31/19
545945/31/20
2102012/31/18
2102012/31/19
2102012/31/20
1149912/31/18

 

DROP ALL DATES THAT ARE NOT 12/31. 

1 ACCEPTED SOLUTION

Accepted Solutions
3 REPLIES 3
Reeza
Super User
if month(data_date)=12 and day(data_date)=31;
ballardw
Super User

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.

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
  • 378 views
  • 1 like
  • 3 in conversation