Help using Base SAS procedures

Update all cell in table based on conditions

Accepted Solution Solved
Reply
Contributor
Posts: 60
Accepted Solution

Update all cell in table based on conditions

Hi

How to update all cell in table based on value in cell no matters in which column they are?

data work;

input week pert sum tar west;

datalines;

18 200  8400 . 100

19 . 6970 6720 .

20 200 . 9766  .

21 .  8400 . 390

22 100 . 8400 .

;

run;

How to update (.) with (0) in whole table?

Thank you in advance

Bob


Accepted Solutions
Solution
‎08-28-2013 05:48 AM
Super Contributor
Posts: 297

Re: Update all cell in table based on conditions

DATA WANT;

SET HAVE;

ARRAY NVARS _NUMERIC_;

DO I = 1 TO DIM(NVARS);

NVARS{I} = TRANSLATE(NVARS{I},0,.);

END;

RUN;

View solution in original post


All Replies
Solution
‎08-28-2013 05:48 AM
Super Contributor
Posts: 297

Re: Update all cell in table based on conditions

DATA WANT;

SET HAVE;

ARRAY NVARS _NUMERIC_;

DO I = 1 TO DIM(NVARS);

NVARS{I} = TRANSLATE(NVARS{I},0,.);

END;

RUN;

Super Contributor
Posts: 297

Re: Update all cell in table based on conditions

If you only want to change the presentation of the missing value, you could use the missing = option:

options missing='0';

data have;

input week pert sum tar west;

datalines;

18 200  8400 . 100

19 . 6970 6720 .

20 200 . 9766  .

21 .  8400 . 390

22 100 . 8400 .

;

run;

Contributor
Posts: 60

Re: Update all cell in table based on conditions

Hi Scoot

Thank you very much

Working like a charm.

Bob

Super Contributor
Posts: 297

Re: Update all cell in table based on conditions

Glad I could help.

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 237 views
  • 6 likes
  • 2 in conversation