Hi,
I am trying to create reduce variable from below data, reduce value starts from 0 and increases if any reduction in dose and retains tilll next reduction.
I have data like below
Can anyone provide the logic for this.
Thanks,
Adi
data want;
set have;
by id;
if first.id then reduce=0;
reduce+(dif(dose)<0 and not first.id);
run;
data want;
set have;
by id;
if first.id then reduce=0;
reduce+(dif(dose)<0 and not first.id);
run;
Somehow this is not working with my data, is there any other way?
Providing data as a screen capture isn't helpful, as we can't run code against a screen capture. The proper way to provide data is in a SAS data step, instructions are here: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/
Saying "it doesn't work" doesn't help either. We need details, we need your data, we need to see your code. What about it doesn't work? Is there an error in the log? We will need to see your log in order to diagnose errors in the log. Or if the output wrong, if so please show us and explain.
Also, please don't post the same question more than once.
From this point forward, all discussion of this question should be in your other thread at https://communities.sas.com/t5/SAS-Programming/Assign-sequence-based-dose-starting-from-zero/m-p/768...
I will not discuss this topic further in this thread, all comments should go to the other thread.
@chinna0369 wrote:
Somehow this is not working with my data, is there any other way?
Provide example data in usable form. Post your data as a data step with datalines, as I showed you here.
We cannot code and test against pictures, we need usable data. DO NOT SKIP THE ABOVE.
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: