BookmarkSubscribeRSS Feed
SAShole
Pyrite | Level 9

Hi All,

     I have a data set with a named range that has a bunch of missing values. i want to fill in those missing values based off a condition of another variable (not in the named range). i know how to do this using array processing but was wondering if it is possible to do so in the way i've outline below.

Here is a fictitious data set to simplify my problem,

data have;

  input (x1-x3) (2.) some_number;

  cards;

. . . .

. . . 3

. . . 4

;

run;

data want;

  set have;

  if some_number > 0 then (x1-x3) = 0;

run;

2 REPLIES 2
data_null__
Jade | Level 19

data X2Zero;

   if 0 then set have(keep=x:);

   retain _all_ 0;

   output;

   stop;

   run;

data have;

   modify have;

   if some_number gt 0 then do point=1;

      set X2Zero point=point;

      replace;

      end;

   run;

proc print data=have;

   run;

Haikuo
Onyx | Level 15

No array().

data have;

infile cards truncover;

  input (x1-x3) (2.) some_number;

  cards;

. . . .

. . . 3

. . . 4

;

proc sql NOPRINT;

select cats('',name,'','=','0')  into :lst separated by '; ' from dictionary.columns where libname='WORK' AND MEMNAME='HAVE' and name ne 'some_number';    quit;

data want;

  set have;

  if some_number > 0 then do;

     &lst;

  end;

run;

proc print;run;

Haikuo

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 745 views
  • 6 likes
  • 3 in conversation