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

CFC_SAS_Communities_400x225.jpgCFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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