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

Hey there, as the title says, how can I make the numberic missing value (format: BEST12., informat: 12.) showed as 'NA' in below data set?

I tried to use put() statement to transform numeric variables to character first, but the transformation doesn't work.

 

qq.PNG

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Haris
Lapis Lazuli | Level 10

You need to assign the format to your variables too.  This code works for me.  You may also need to tell your data viewer what to display: different machines have different defaults and can either show raw or formatted values.

 

proc format; value NA .='NA'; run;

data test;
	a = .; b=1; c=1; output;
	a = 1; b=.; c=1; output;
	a = 1; b=1; c=.; output;
	format a b c NA.;
run;

View solution in original post

5 REPLIES 5
Haris
Lapis Lazuli | Level 10
There's not enough detail in your post to determine exactly what you are trying to do and where you want 'NA' to show up: data view, report, some sort of procedure output?

Try to apply a format:
PROC FORMAT; value NA .='NA'; run;
zhouxysherry
Fluorite | Level 6

I would like 'NA' to show in data view.

 

I tried PROC FORMAT, but it doesn't work.

error.PNG

Haris
Lapis Lazuli | Level 10

You need to assign the format to your variables too.  This code works for me.  You may also need to tell your data viewer what to display: different machines have different defaults and can either show raw or formatted values.

 

proc format; value NA .='NA'; run;

data test;
	a = .; b=1; c=1; output;
	a = 1; b=.; c=1; output;
	a = 1; b=1; c=.; output;
	format a b c NA.;
run;
ballardw
Super User

The NUMERIC variables of your array ZERO are still numeric.

zero [i] = 'NA' will fail as 'NA' isn't acceptable. And that is what you are doing with the PUT statement.

try

 

data test;

    set output_de21_de42;

    format  _numeric_  trouble.;

run;

David_Luttrell
Obsidian | Level 7

Change the variable(s) to a characters

 

Use a case statement to apply the NA values in the transformation otherwise that value.

 

It may be more appropriate to transpose the dataset before applying as this will mean less cols to change.

sas-innovate-2024.png

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.

 

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
  • 5 replies
  • 8952 views
  • 1 like
  • 4 in conversation