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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.