Help using Base SAS procedures

Macro to change variable values

Reply
N/A
Posts: 0

Macro to change variable values

Hi Folks,
I have a dataset with 30 different variables with each cell being either a ONE or a . ( missing numeric value, Now I would like to change the . ( numeric blank) to ZERO. I don't want to use proc format. I just need a physical ZERO in place of that . (BLANK). I can use a if..then 30 times to do that .. but can someone suggest a better way.

Thanks

Matt
Super Contributor
Super Contributor
Posts: 3,174

Re: Macro to change variable values

Use a DATA step with an ARRAY, as coded below:

ARRAY ANUMVARS (*) _NUMERIC_;
DO I=1 TO DIM(ANUMVARS);
IF ANUMVARS(I) = . THEN ANUMVARS(I) = 0;
END;


Scott Barry
SBBWorks, Inc.
Respected Advisor
Posts: 3,777

Re: Macro to change variable values

With SAS/Stat procedure STDIZE you can easily replace all those missing values with any value you like including zero.
Valued Guide
Posts: 2,175

Re: Macro to change variable values

If you only want to see missings as physical zero in reporting, then change no data! All you need - only before the reporting procedure, just set [pre] option missing= '0' ;[/pre]
Ask a Question
Discussion stats
  • 3 replies
  • 124 views
  • 0 likes
  • 4 in conversation