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

Hi,

I have an issue with one of the datasets I am working on. The two date fields in my dataset are as below -

48

ELGBGNDT

Num

8

MMDDYY10.

34

ELIGDT

Num

8

MMDDYY10.

DATE9.

ELIGDT

When I run this code, I get back 0 records which I am not able to resolve.

data MHTST.MKTLVL_MBR_201112;

set MHTST.FINALMBR;

if eligdt='12/31/2011' then output;

run;

These are the values for the two variables in the sas dataset.

ELIGDT      ELGBGNDT

07/31/201107/01/2011
08/31/201108/01/2011
09/30/201109/01/2011
10/31/201110/01/2011
11/30/201111/01/2011
12/31/201112/01/2011

Any suggestions are appreciated.

Thanks,
saspert

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

add a d onto your if statement and stating the date in date9. format.  i.e.,

if eligdt='31dec2011'd then output;


Note: corrected suggestion after seeing the suggestion made by .

View solution in original post

2 REPLIES 2
art297
Opal | Level 21

add a d onto your if statement and stating the date in date9. format.  i.e.,

if eligdt='31dec2011'd then output;


Note: corrected suggestion after seeing the suggestion made by .

Ankitsas
Calcite | Level 5

Hi saspert,

Please look at the below code and it will serve your purpose.

data a;

input date1 : mmddyy10. date2 : mmddyy10.;

format date1 date2 date9.;

datalines;

07/31/2011 07/01/2011

12/31/2011 12/01/2011

;

data b;

set a;

if date1='31dec2011'd then output;     // adding a 'd' is possible only with date9. date format and not with mmddyy date format.

run;

Note - In the above example i am reading  the nonstandard date value , sas stores date values in numeric format, then i am using format statement to convert the date value into a comparable format.

Let me know in case of any queries.

Thanks,

Ankit

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
  • 2 replies
  • 799 views
  • 0 likes
  • 3 in conversation