DATA Step, Macro, Functions and more

Converts Missing values to Zero in SAS using Array statement?

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

Converts Missing values to Zero in SAS using Array statement?

Dear All,

Is it possible, to write a program that converts missing values to zero and values of zero to missing for numeric variables using array statement?

Appreciate and thanks a lot for help.

Regards,

S Ravuri.


Accepted Solutions
Solution
‎03-16-2012 08:28 AM
Respected Advisor
Posts: 3,156

Re: Converts Missing values to Zero in SAS using Array statement?

Posted in reply to sambasiva_ravuri_tcs_com

S Ravuri,

It also "will be really helpful going forward" if you could mark Ksharp's answer as "Correct". One 'Click' of yours will help saving many others who share same interest many minutes by leading them right to the point. Besides, who would want to watch movies without endings at the first place?Smiley Wink

Thanks,

Haikuo

View solution in original post


All Replies
Super User
Posts: 10,046

Converts Missing values to Zero in SAS using Array statement?

Posted in reply to sambasiva_ravuri_tcs_com

From mssing value to zero.

data worked;
input _QueueName $24. _tran_dt :mmddyy8. _tran_tm acct_num workedkey _acct_num;
format _tran_dt mmddyy8. acct_num 16.;

cards;
Inbound                       3/8/2012    172000      3000000000064278  .      3000000000064278
C-VXX-D-CP-XXXXXXX-XXXX       3/7/2012    .     3000000000064278  11918651      3000000000064278
N-PXX-N-CP-XXXXXXXXXXXXX      3/3/2012    213400      2000000000885230  11886991      2000000000885230
N-2XX-N-KE-XXXXXXX            3/4/2012    170800      1000000000801180  11895835      1000000000801180
;
run;
data worked;
 set worked;
 array _x{*} _numeric_;
 do i=1 to dim(_x);
  if missing(_x{i}) then _x{i}=0;
 end;
run;







From zero to missing value



data worked;
input _QueueName $24. _tran_dt :mmddyy8. _tran_tm acct_num workedkey _acct_num;
format _tran_dt mmddyy8. acct_num 16.;

cards;
Inbound                       3/8/2012    172000      3000000000064278  0      3000000000064278
C-VXX-D-CP-XXXXXXX-XXXX       3/7/2012    0     3000000000064278  11918651      3000000000064278
N-PXX-N-CP-XXXXXXXXXXXXX      3/3/2012    213400      2000000000885230  11886991      2000000000885230
N-2XX-N-KE-XXXXXXX            3/4/2012    170800      1000000000801180  11895835      1000000000801180
;
run;
data worked;
 set worked;
 array _x{*} _numeric_;
 do i=1 to dim(_x);
  if _x{i}=0 then _x{i}=.;
 end;
run;



Ksharp

Contributor
Posts: 42

Converts Missing values to Zero in SAS using Array statement?

Hello Ksharp,

Codes are worked very well and i really appreciate for your help.

If you don't mind, what is the significance of "_numeric_ "  Automatic variable which you used in the code ?

Can you please share if you have a list of Automatic variables in SAS with explanations and that will be really helpful going forward.

Regards,

S Ravuri.

Solution
‎03-16-2012 08:28 AM
Respected Advisor
Posts: 3,156

Re: Converts Missing values to Zero in SAS using Array statement?

Posted in reply to sambasiva_ravuri_tcs_com

S Ravuri,

It also "will be really helpful going forward" if you could mark Ksharp's answer as "Correct". One 'Click' of yours will help saving many others who share same interest many minutes by leading them right to the point. Besides, who would want to watch movies without endings at the first place?Smiley Wink

Thanks,

Haikuo

Super User
Posts: 10,046

Re: Converts Missing values to Zero in SAS using Array statement?

Posted in reply to sambasiva_ravuri_tcs_com

_numeric_ is a representor of all the numeric variables in this dataset.

There are some other variable listing way which can save you lots of time in the documentation.You should search it on your own  at support.sas.com   .

Ksharp

Regular Contributor
Posts: 184

Re: Converts Missing values to Zero in SAS using Array statement?

Posted in reply to sambasiva_ravuri_tcs_com

It's not an automatic variable. It is a SAS Variable List.

http://support.sas.com/documentation/cdl/en/lrcon/62753/HTML/default/viewer.htm#p0wphcpsfgx6o7n1sjtq...

sambasiva.ravuri@tcs.com wrote:

Hello Ksharp,

Codes are worked very well and i really appreciate for your help.

If you don't mind, what is the significance of "_numeric_ "  Automatic variable which you used in the code ?

Can you please share if you have a list of Automatic variables in SAS with explanations and that will be really helpful going forward.

Regards,

S Ravuri.

Contributor
Posts: 42

Re: Converts Missing values to Zero in SAS using Array statement?

Posted in reply to sambasiva_ravuri_tcs_com

Haikuo,

Am already did that. Thanks for suggestion. Am between couple of meetings.So that is the reason am not able to do it on time and am sorry for that.

Regards,

S Ravuri.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 3476 views
  • 3 likes
  • 4 in conversation