BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mona4u
Lapis Lazuli | Level 10

I have this sample of the variable which is the result of merging datasets 

I need to know how I can assign blanks for the value of 0 and . if the variables are numeric without mentioning the variables names 

I have too many variables and I don't want to do it by if statement for each variable individually

do you have suggestions?

 

this is my sample 

 

ESCGIOpen_GITOTAL_PACs_GIhptotal_cases1hp_pendingreview
.....
.....
.....
.....
005300
.....
.....
.....
.....
.....
001..
.....
.....
.....
.....
001..
.....
.....
002500
.....
001..
001..
001..
.....
.....
001..
.....
002..
.....
00400
00600
00200
00200
.....
00200
00200
00100
.....
00200
.....
001..
.....
.....
.....
212400
.....
001000
.....
.....
.....
.....
00100
00101
.....
.....
.....
.....
.....
.....
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use a format.

 

proc format;
value my_cust_fmt
0, . =' '
other = [best8.];
run;

data have;
set sashelp.class;
if age in (12, 10) then call missing(age, height);

format _numeric_ my_cust_fmt.;
run;

View solution in original post

6 REPLIES 6
SuryaKiran
Meteorite | Level 14
data want;
set have;
array change_num _numeric_;
do over change_num;
if change_num=. then change_num=0;
end;
run;

Check this, will change all numeric with missing values to 0

 

Thanks,
Suryakiran
LinusH
Tourmaline | Level 20
You can't assign a blank to a numerical column.
You can however chose to display missing values as a blank using the MISSING system option.
Data never sleeps
Astounding
PROC Star

There is no such thing.  It is not possible for numeric variables to take on a value of blank.  The best you can do is this:

 

options missing=" ";

 

That causes missing values for numeric variables to be displayed as a blank when reporting.  But the value that is stored, and the value that you would refer to in your programming statements is still a dot not a blank.

 

If you wish, you can convert zero to a missing value:

 

if var = 0 then var = .;

 

After that, the missing= option would apply.  First, you have to decide whether changing zero to missing is actually destroying some of your information.

mona4u
Lapis Lazuli | Level 10

This is a good soln but I have to call each variable   if var = 0 then var = .;  which will consume time 

Reeza
Super User

Use a format.

 

proc format;
value my_cust_fmt
0, . =' '
other = [best8.];
run;

data have;
set sashelp.class;
if age in (12, 10) then call missing(age, height);

format _numeric_ my_cust_fmt.;
run;
mona4u
Lapis Lazuli | Level 10

Thanks so much this is so efficient 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 4866 views
  • 4 likes
  • 5 in conversation