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/2011 | 07/01/2011 |
08/31/2011 | 08/01/2011 |
09/30/2011 | 09/01/2011 |
10/31/2011 | 10/01/2011 |
11/30/2011 | 11/01/2011 |
12/31/2011 | 12/01/2011 |
Any suggestions are appreciated.
Thanks,
saspert
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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.