BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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;

View solution in original post

12 REPLIES 12
novinosrin
Tourmaline | Level 20

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;

Reeza
Super User
INPUT requires a character input, but it would be nice if could be directly converted for sure.
http://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p19en16vskd2vhn1vwmxpxnglxxs.htm&...
PaigeMiller
Diamond | Level 26

Thanks, @novinosrin and @Reeza, I knew it was something simple.

 

But you don't have to call me "sir" Smiley Happy

--
Paige Miller
novinosrin
Tourmaline | Level 20

"But you don't have to call me "sir" Smiley Happy"

 

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!

Astounding
PROC Star

If you have control over this part of the process, the program would work if you add a $:

 

input date $;

ballardw
Super User

@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.

novinosrin
Tourmaline | Level 20

@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

novinosrin
Tourmaline | Level 20

yes @Reeza  That's right

Reeza
Super User

Definitely a bot, less than a second after the post. Interesting thing is they're not even showing online. 

novinosrin
Tourmaline | Level 20

@ChrisHemedinger or @AnnaBrown  may help fix this ? Thanks @Reeza for immediate attention. Much needed and appreciated from my end.

ChrisHemedinger
Community Manager

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.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 12 replies
  • 1998 views
  • 7 likes
  • 6 in conversation