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!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.