I've imported an excel sheet into SAS EG using the import wizard and the date values are character values that look like 2013/03/01. I need to convert these to SAS Date values, but when I try to use input the values just come out as missing values. How can I properly convert these character dates to SAS date values? Thanks.
You didn't show the code you used. The following, using the anydtdte informat worked for me:
data have; input date $10.; cards; 2013/03/01 2012/04/02 ; data want; set have (rename=(date=_date)); format date date9.; date=input(_date,anydtdte10.); run;
HTH,
Art, CEO, AnalystFinder.com
You didn't show the code you used. The following, using the anydtdte informat worked for me:
data have; input date $10.; cards; 2013/03/01 2012/04/02 ; data want; set have (rename=(date=_date)); format date date9.; date=input(_date,anydtdte10.); run;
HTH,
Art, CEO, AnalystFinder.com
@art297 This does indeed turn it into a SAS date, however ultimately what I'm trying to do after the conversion is subset a dataset by an expression:
proc sql noprint;
select ID into :ID_List_2010 separated by ' '
from EGTASK.'ID FROM DATES_UPDATED'n
where from_date < '01jan2011'd;
quit;
But it is giving me the error:
Expression using less than (<) has components that are of different data types.
Sorry, I did not specify before that I wanted to do a condition on dates.
I'd think that your log shows some other error before that. The following worked for me:
input id $ date $10.; cards; a 2013/03/01 b 2010/03/01 c 2010/04/02 ; data want; set have (rename=(date=_date)); format from_date date9.; from_date=input(_date,anydtdte10.); run; proc sql noprint; select ID into :ID_List_2010 separated by ' ' /* from EGTASK.'ID FROM DATES_UPDATED'n*/ from want where from_date < '01jan2011'd ; quit;
Art, CEO, AnalystFinder.com
Try defining the date columns in Excel as type DATE to begin with, then re-import.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.