Hi guys,
I am working on a data-set containing multiple row for each studycode. there are other variables namely atc_code and date_of_supply. I want to indicate those studycodes whose consecutive date_of _supply for a specific atc group (several atc_code constitutes a group. e.g: C100BS, C11BD4, C10AA01, C112KN CONSTITUTES ONE ATC GROUP ) is less than say 60 days.
I WANT IT ALL IN A SINGLE FILE. CAN ANYONE HELP ME OUT? SAMPLE XLS IS ATTACHED
Can you please paste the sample as text here and also a sample of your want.I would like a sample of your wanted output. Thank you!
This code will work, if not try to debug it, there might be some problem with position of retain variable.
proc sort data=sheet3;
by studycode atc_codes date_of_supply;
run;
data final_extract(drop=date_of_supply1);
set sheet3;
retain date_of_supply1;
by studycode atc_codes;
if first.atc_codes then do;
diff=0;
date_of_supply1=date_of_supply;
end;
else do;
diff=date_of_supply1
date_of_supply1=date_of_supply;
if diff ge 60 then output;
end;
run;
Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
Many Thanks
@ballardw This whole text should be on the "create post" page.
@ChrisHemedinger Is it possible to add this text directly as part of the "New post" page? Most posted data is still in the wrong format.
@ChrisNZ We'll look into it, especially as we work on our project for creating a more responsive-friendly design.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.