DATA Step, Macro, Functions and more

INPUT Function unexpectedly producing missing values

Accepted Solution Solved
Reply
Respected Advisor
Posts: 3,000
Accepted Solution

INPUT Function unexpectedly producing missing values

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

Accepted Solutions
Solution
4 weeks ago
PROC Star
Posts: 1,792

Re: INPUT Function unexpectedly producing missing values

[ Edited ]
Posted in reply to PaigeMiller

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


All Replies
Solution
4 weeks ago
PROC Star
Posts: 1,792

Re: INPUT Function unexpectedly producing missing values

[ Edited ]
Posted in reply to PaigeMiller

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;

Super User
Posts: 23,700

Re: INPUT Function unexpectedly producing missing values

Posted in reply to PaigeMiller
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&...
Respected Advisor
Posts: 3,000

Re: INPUT Function unexpectedly producing missing values

[ Edited ]

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

 

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

--
Paige Miller
PROC Star
Posts: 1,792

Re: INPUT Function unexpectedly producing missing values

Posted in reply to PaigeMiller

"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!

Super User
Posts: 6,762

Re: INPUT Function unexpectedly producing missing values

Posted in reply to PaigeMiller

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

 

input date $;

Super User
Posts: 13,523

Re: INPUT Function unexpectedly producing missing values

Posted in reply to Astounding

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

PROC Star
Posts: 1,792

Re: INPUT Function unexpectedly producing missing values

@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

Super User
Posts: 23,700

Re: INPUT Function unexpectedly producing missing values

Posted in reply to novinosrin
@novinosrin @Sas_XXXX user name?
PROC Star
Posts: 1,792

Re: INPUT Function unexpectedly producing missing values

yes @Reeza  That's right

Super User
Posts: 23,700

Re: INPUT Function unexpectedly producing missing values

Posted in reply to novinosrin

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

PROC Star
Posts: 1,792

Re: INPUT Function unexpectedly producing missing values

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

Community Manager
Posts: 3,424

Re: INPUT Function unexpectedly producing missing values

Posted in reply to novinosrin

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 12 replies
  • 209 views
  • 7 likes
  • 6 in conversation