BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chinna0369
Pyrite | Level 9

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

 

anyalamadugu_0-1632238026857.png

 

Can anyone provide the logic for this.

 

Thanks,

Adi

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

data want;
    set have;
    by id;
    if first.id then reduce=0;
    reduce+(dif(dose)<0 and not first.id);
run;
--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

data want;
    set have;
    by id;
    if first.id then reduce=0;
    reduce+(dif(dose)<0 and not first.id);
run;
--
Paige Miller
chinna0369
Pyrite | Level 9

Somehow this is not working with my data, is there any other way?

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Kurt_Bremser
Super User

 


@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.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 5 replies
  • 593 views
  • 0 likes
  • 3 in conversation