HELLO, SOMEONE WOULD KNOW HOW I CAN REPLACE VALUES '.' EXISTING ON A SAS TABLE FOR 0?
If what you're asking is how to replace missing numerical values (.) with zero, then do
data have;
input ID$ var1 var2 var3;
datalines;
1 . 3 4
2 2 0 .
3 . . 3
4 . 8 .
5 5 . .
;
proc stdize data=have out=want reponly missing=0;
run;
Hi could you post an sample of what your dataset contains. i.e a sample input & sample output(requirement)
MY INPUT BASE CONTAINS VALUES (.) AS BELOW WITH 50 ROWS AND 754 COLUMNS. MY OUTPUT BASE WILL BE EVEN WITH VALUES (.) REPLACED BY 0. THE DOUBT IS HOW TO MAKE THIS REPLACEMENT ON ALL COLUMNS CONTAINING (.)
COLUMN 1 COLUMN2 COLUMN3....COLUMN754
INDUST . -0.0660 .
.....
Hi @EloarL Thank you. Did you try the solution given by @PeterClemmensen ?
@EloarL wrote:
MY INPUT BASE CONTAINS VALUES (.) AS BELOW WITH 50 ROWS AND 754 COLUMNS. MY OUTPUT BASE WILL BE EVEN WITH VALUES (.) REPLACED BY 0. THE DOUBT IS HOW TO MAKE THIS REPLACEMENT ON ALL COLUMNS CONTAINING (.)
COLUMN 1 COLUMN2 COLUMN3....COLUMN754
INDUST . -0.0660 ......
Please do not use all capitol letters in posts. It is hard to read and considered to be shouting.
The question is do you want to actually change missing to zero for calculations OR for displaying 0 optionally instead of the default period character for missing values?
If you want to display 0 instead of missing in a report, proc print or similar output then setting the system missing option may be what you want:
data junk; x=25; y=.; run; options missing='0'; proc print; run;
will Display the missing value for the y variable as 0.
You can use any single character as the missing value as desired.
It will stay in affect until you change the option with another Options missing assignment.
If want to change the actual value to 0 then you will need to use data step code or other transformations.
A third option would be create one or more custom formats for the variables that will display 0 instead of . for missing.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.