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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 680 views
  • 6 likes
  • 3 in conversation