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
ESCGI | Open_GI | TOTAL_PACs_GI | hptotal_cases1 | hp_pendingreview |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
0 | 0 | 53 | 0 | 0 |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
0 | 0 | 1 | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
0 | 0 | 1 | . | . |
. | . | . | . | . |
. | . | . | . | . |
0 | 0 | 25 | 0 | 0 |
. | . | . | . | . |
0 | 0 | 1 | . | . |
0 | 0 | 1 | . | . |
0 | 0 | 1 | . | . |
. | . | . | . | . |
. | . | . | . | . |
0 | 0 | 1 | . | . |
. | . | . | . | . |
0 | 0 | 2 | . | . |
. | . | . | . | . |
0 | 0 | 4 | 0 | 0 |
0 | 0 | 6 | 0 | 0 |
0 | 0 | 2 | 0 | 0 |
0 | 0 | 2 | 0 | 0 |
. | . | . | . | . |
0 | 0 | 2 | 0 | 0 |
0 | 0 | 2 | 0 | 0 |
0 | 0 | 1 | 0 | 0 |
. | . | . | . | . |
0 | 0 | 2 | 0 | 0 |
. | . | . | . | . |
0 | 0 | 1 | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
2 | 1 | 24 | 0 | 0 |
. | . | . | . | . |
0 | 0 | 10 | 0 | 0 |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
0 | 0 | 1 | 0 | 0 |
0 | 0 | 1 | 0 | 1 |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | . | . |
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;
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
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.
This is a good soln but I have to call each variable if var = 0 then var = .; which will consume time
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;
Thanks so much this is so efficient
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.
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.