DATA Step, Macro, Functions and more

Conditionals and Named Range

Reply
Contributor
Posts: 62

Conditionals and Named Range

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;

Respected Advisor
Posts: 3,799

Re: Conditionals and Named Range

data X2Zero;

   if 0 then set have(keep=xSmiley Happy;

   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;

Respected Advisor
Posts: 3,156

Re: Conditionals and Named Range

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

Ask a Question
Discussion stats
  • 2 replies
  • 161 views
  • 6 likes
  • 3 in conversation