BookmarkSubscribeRSS Feed
nid197
Obsidian | Level 7

hello,

  

I am stuck with something please help me out with this..

I have a table as-

 

wr_no    rfa_no   stk_ref     status

1               1          x             fp

1               2          x             fp

1               1          y             fp

1               1          x             nu

2               1

2               1          x             fp

1               1          x             gd

1               2

1               1          x             gp

1               1          x             gc

 

I want to create  a flag as 0 for records having status 'nu' i.e for every  'nu' of  stk_ref i want to flag 0  'fp' but not ('gd','gp','gc') with reference to my stk_ref ,wr_no and rfa_no.so basically here i want to flag 0 1st and 4th record 

because for the same stk_ref i got 'nu' which has unique  wr_no and unique rfa_no.there are  blank stk_ref and status also for which the flag should be zero.

 

And the table contains 5billion rows.

 

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Can you show what the outpu should look like.  The simplest method is to extract the data with nu, and merge this back to your original data base on your identifier variables, and then you can blank out where not needed, something like (not tested):

data temp;
  set have (where=(status="nu"));
run;

data want;
  merge have temp (rename=(status=mrg_status));
  by wr_no rfa_no stk_ref;
  if status ne "fp" then mrg_status="";
run;
nid197
Obsidian | Level 7

It should look like this-

 

OUTPUT:-

 

wr_no    rfa_no   stk_ref     status   flag

1               1          x             fp         0

1               2          x             fp         1

1               1          y             fp         1

1               1          x             nu        0

2               1                                     0

2               1          x             fp         1

1               1          x             gd        1

1               2                                     0

1               1          x             gp         1

1               1          x             gc         1

 

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
  • 683 views
  • 0 likes
  • 2 in conversation