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

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



1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

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;

View solution in original post

8 REPLIES 8
stat_sas
Ammonite | Level 13

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;

ilikesas
Barite | Level 11

Thanks a lot stat@sas!

DBailey
Lapis Lazuli | Level 10

Isn't the value for name going to be a period? Shouldn't it be

if name='.' then name='Missing';

data_null__
Jade | Level 19

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. 

data dot_or_not;
   input a $ @1 @;
   input b $char2. @1 @;
   input c $2. @1 @;
   w=2;
  
input d $varying2. w;
  
cards;
.  x
.  y
;;;;
   run;
proc print;
  
run;

12-18-2014 7-14-06 AM.png
DBailey
Lapis Lazuli | Level 10

nice to know.  I'm figured that STAT wouldn't have made an error like that..but had to ask.

stat_sas
Ammonite | Level 13

Hi DBailey,

Thanks for highlighting this. I also learned as a result of your question from master data_null_.

Regards,

Naeem

Jagadishkatam
Amethyst | Level 16

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,
Jag
ilikesas
Barite | Level 11

thanks Jagadishkatam, you taught me a new function!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 8 replies
  • 3196 views
  • 7 likes
  • 5 in conversation