Hi,
Suppose I have the following SAS code:
data numbers;
input id name$;
datalines;
1 A
2 B
3 A
4 .
5 B
6 .
7 B
8 A
9 A
10 .
;
run;
Some names are missing and I have the dot "." that signifies that these names are missing, but is it possible to have instead of the dot the actual word "Missing"?
Thank you
data numbers;
input id name$;
if name=' ' then name='Missing';
datalines;
1 A
2 B
3 A
4 .
5 B
6 .
7 B
8 A
9 A
10 .
;
run;
data numbers;
input id name$;
if name=' ' then name='Missing';
datalines;
1 A
2 B
3 A
4 .
5 B
6 .
7 B
8 A
9 A
10 .
;
run;
Thanks a lot stat@sas!
Isn't the value for name going to be a period? Shouldn't it be
if name='.' then name='Missing';
DBailey wrote:
Isn't the value for name going to be a period? Shouldn't it be
if name='.' then name='Missing';
No the $ INFORMAT (variables A and C) reads dot as missing to accommodate list input which needs place holder.
nice to know. I'm figured that STAT wouldn't have made an error like that..but had to ask.
Hi DBailey,
Thanks for highlighting this. I also learned as a result of your question from master data_null_.
Regards,
Naeem
Alternatively by ifc function
data numbers;
input id name$;
name=ifc(name='','Missing',name);
datalines;
1 A
2 B
3 A
4 .
5 B
6 .
7 B
8 A
9 A
10 .
;
run;
Thanks,
Jag
thanks Jagadishkatam, you taught me a new function!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.