Simple problem, I have received a SAS data set where dates are not SAS date values, but are integers of the form 20180621, meaning June 21, 2018. I thought a simple use of the INPUT Function would turn these into SAS date values, but apparently not.
SAS code to reproduce (a small part of) the data set I received:
data a;
input date;
cards;
20180621
20180504
;
run;
So, I have received the data, it looks like 20180621, and now I want to use the INPUT function
data b;
set a;
date1=input(date,yymmdd8.);
run;
but this produces missing values instead of SAS Date values. Why? And how do I fix it?
Sir, are you missing the first convert to char from num?
data a;
input date;
new_date=input(put(date,8.),yymmdd8.);
format new_Date yymmdd10.;
cards;
20180621
20180504
;
run;
data a;
input date;
cards;
20180621
20180504
;
run;
data b;
set a;
new_date=input(put(date,8.),yymmdd8.);
format new_Date yymmdd10.;
run;
Sir, are you missing the first convert to char from num?
data a;
input date;
new_date=input(put(date,8.),yymmdd8.);
format new_Date yymmdd10.;
cards;
20180621
20180504
;
run;
data a;
input date;
cards;
20180621
20180504
;
run;
data b;
set a;
new_date=input(put(date,8.),yymmdd8.);
format new_Date yymmdd10.;
run;
Thanks, @novinosrin and @Reeza, I knew it was something simple.
But you don't have to call me "sir"
"But you don't have to call me "sir" "
When I do, I really mean it and value those special few here. I seriously follow the highly accomplished yet humble personalities like you here and I shamelessly and openly admit to being biased to read their(you in the list) posts only. Thank you!
If you have control over this part of the process, the program would work if you add a $:
input date $;
@Astounding wrote:
If you have control over this part of the process, the program would work if you add a $:
input date $;
@Astounding I suspect Paige actually received a .sas7bdat and wasn't reading an external file from scratch.
@Everybody,, Some BOT seems to trigger LIKE for every post if you may have noticed or not. lol. I am not complaining though but so weird
yes @Reeza That's right
Definitely a bot, less than a second after the post. Interesting thing is they're not even showing online.
@ChrisHemedinger or @AnnaBrown may help fix this ? Thanks @Reeza for immediate attention. Much needed and appreciated from my end.
Hi all - thanks for bringing this to our attention. I've removed the Likes (regardless of how deserving your posts might have been) and we're looking into the cause.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.