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

Hi,

I am doing some research on Crash data and I want to investigate few crashes happened on particular dates.

My data is in MDY format and these are the dates i  want to investigate (11/5/2017),(12/31/2017) &(01/04/2018) 

I know the function to select dates between two periods, not sure of selecting particular dates.

Your advice is much appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data want;
   set have;
   where date in ('05nov2017'd, '31dec2017'd, '04jan2018'd);
run;

View solution in original post

5 REPLIES 5
Satish_Parida
Lapis Lazuli | Level 10
  1. If the crash_date are in numeric form just displayed as 11/5/2017 in the dataset then you can try a datastep like following
    1. data output;
      set input;
      where crash_date in ('05Nov2017'd, '31Dec2017'd, '04Jan2018'd);
      run;
  2. But if the crash_date is characters then the following will work.
    1. data output;
      set input;
      where input(crash_date,mmddyy10.) in ('05Nov2017'd, '31Dec2017'd, '04Jan2018'd);
      run;
BIDD
Fluorite | Level 6
Thanks for ur help, it works...cheers
FredrikE
Rhodochrosite | Level 12

Depends on the actual format of the dates stored in your table.

 

If the dates are in text format this might work:

data...

 set ...

 if date in ('11/5/2017' '12/31/2017' '01/04/2018');

run;

 

If the dates are in numeric format then this might work:

data...

 set ...

 if date in ('05NOV2017'd '31DEC2017'd '04JAN2018'd);

run;

 

//Fredrik

PeterClemmensen
Tourmaline | Level 20
data want;
   set have;
   where date in ('05nov2017'd, '31dec2017'd, '04jan2018'd);
run;
BIDD
Fluorite | Level 6
Thanks for ur help, it works...cheers

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 996 views
  • 2 likes
  • 4 in conversation