BookmarkSubscribeRSS Feed
strqimr
Fluorite | Level 6

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

7 REPLIES 7
novinosrin
Tourmaline | Level 20

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!

Satish_Parida
Lapis Lazuli | Level 10

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;
ballardw
Super User

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.

ChrisNZ
Tourmaline | Level 20

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

ChrisHemedinger
Community Manager

@ChrisNZ We'll look into it, especially as we work on our project for creating a more responsive-friendly design.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 978 views
  • 3 likes
  • 6 in conversation