BookmarkSubscribeRSS Feed
2018studentship
Calcite | Level 5
 
1 REPLY 1
ballardw
Super User

@2018studentship wrote:

Hello there, 

 

I'm a beginner in SAS and am working on a project that requires me to create codes for drug regimens. I have generated data that give the start/end date of each episode of a different class of drug used, and start/end date of each drug regimen. My logic is that if the end date of a regimen is within the range of an episode, then the class of drug associated with that episode will be added to the regimen code. Each observation will also have an associated patient code.

So for the data below which all belong to the same patient, the regimen code should appear as:

image.png

  1. mb
  2. b
  3. mb
  4. msb
  5. ms
  6. .
  7. ms
  8. .
  9. ms
  10. m
  11. .
  12. m

 

If possible, could I achieve this through using arrays and macros without using sql? I am using SAS 9.4, any ideas would be greatly appreciated.

 

 


Some things that may help get (better) answers:

Show the patient identification in the data. It is going to be hard to tell which patient is involved otherwise.

Describe and show the connection between your example start data and the "result". The result is not at all obvious what the connection may be as there are 1) no values of 1, 2, 3 etc in the example data and 2) why you may have an mb and b in the output and 3) where do the missing values come from?

How do we know what or when an "episode" occurs? Presumably one of the variables, but you do not tell us which one. and which is the drug regimen.

Also, confirm that your dates are actual SAS date values (numeric with a date format applied) and not character. Otherwise the first step will be to create date values so comparisons can be performed.

 

It is poor technique to discard an approach -without using sql for example- without providing a very good reason why such would be a problem.

 

This sounds like RETAIN for a new combined regimen might be in order

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
  • 1 reply
  • 1026 views
  • 0 likes
  • 2 in conversation