BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
magicdj
Obsidian | Level 7

i set up some missing value as below.  in my excel output, i want the non missing numbers still the numbers, but for missing values , i want it show as NA. is there any way to do it? thanks

 

 

data Have;
Set sashelp.class;
if age=11 then age=.;

run;

proc export data=Have
outfile="/usr/local/SAS/SASUsers/LabRet.excel"
dbms=tab
label
replace;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Why? What extra information does that add?

 

You could define a format that does that.

proc format;
  value na . = 'NA' other=[best12.];
run;

data test;
  set sashelp.class(obs=1);
  do age=age,.,._,.A,.Z ;
    output;
  end;
run;

proc print data=test;
  format age na.;
run;

Result

Obs     Name     Sex        Age         Height    Weight

 1     Alfred     M               14      69       112.5
 2     Alfred     M     NA                69       112.5
 3     Alfred     M                _      69       112.5
 4     Alfred     M                A      69       112.5
 5     Alfred     M                Z      69       112.5

If you want the other 27 missing values to also print as NA then define the format like this instead:

value na ._-.Z = 'NA' other=[best12.];

Or 

value na low-high=[best12.] other='NA';

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Why? What extra information does that add?

 

You could define a format that does that.

proc format;
  value na . = 'NA' other=[best12.];
run;

data test;
  set sashelp.class(obs=1);
  do age=age,.,._,.A,.Z ;
    output;
  end;
run;

proc print data=test;
  format age na.;
run;

Result

Obs     Name     Sex        Age         Height    Weight

 1     Alfred     M               14      69       112.5
 2     Alfred     M     NA                69       112.5
 3     Alfred     M                _      69       112.5
 4     Alfred     M                A      69       112.5
 5     Alfred     M                Z      69       112.5

If you want the other 27 missing values to also print as NA then define the format like this instead:

value na ._-.Z = 'NA' other=[best12.];

Or 

value na low-high=[best12.] other='NA';
magicdj
Obsidian | Level 7

hi, Tom the sas dataset show NA, ut when i export to excel. the result is not show. don't know what happened.

SAS Innovate 2025: 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 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
  • 3 replies
  • 905 views
  • 0 likes
  • 2 in conversation