DATA Step, Macro, Functions and more

How the value "1" was generated ?

Reply
Frequent Contributor
Frequent Contributor
Posts: 76

How the value "1" was generated ?

Dear all,

 

Anybody can tell me how the "hasc = 1  or hasf = 1 "  generated during the following programming ?  Thank you.  Ivy

 

data  test_1 ;
set test;
by ID lot admin_date drug;
retain hasc hasf;
if first.lot then do;
hasc=0;
hasf=0;
end;
if drug = "CAPECITABINE" then do;
if hasf = 1 then drug = "FLUOROURACIL";
else hasc = 1;
end;
if drug = "FLUOROURACIL" then do;
if hasc = 1 then new_drug = "CAPECITABINE";
else hasf = 1;
end;
run;

 

 

Super User
Posts: 17,831

Re: How the value "1" was generated ?

It's a bit circular, To confuse it all, there's a retain statement that keeps the values across the rows, so it looks like it's alternating drugs?

If you post some sample data tracing the program out may help. 

 

HASC=1 if

DRUG=CAPECITABINE and HASF=0

 

HASF=1 if

DRUG=FLUOROURACIL and HASC=1

 

 

 

Ask a Question
Discussion stats
  • 1 reply
  • 150 views
  • 0 likes
  • 2 in conversation