BookmarkSubscribeRSS Feed
Primavera
Quartz | Level 8

Hi all,

I have a dataset of patients using a drug. Each person has used the drug for Total_days and the dosage of each day is shown in dose_day[i]. Most patients have interruptions (days with dose_day[i]=0) when they received the drug. A simplified data set looks like this:

ID Total_days dose_day1 dose_day2 dose_day3 dose_day4 dose_day5 dose_day6 dose_day7 dose_day8 dose_day9 dose_day10 dose_day11 dose_day12 dose_day13 dose_day14 dose_day15 dose_day16 dose_day17 dose_day18 dose_day19 dose_day20 dose_day21 dose_day22 dose_day23 dose_day24 dose_day25
1 18 30 30 30 15 0 0 45 45 45 60 60 0 0 0 45 45 60 60 0 0 0 0 0 0 0
2 25 15 15 15 25 25 25 25 25 40 0 0 0 0 40 40 40 40 40 40 40 40 25 25 25 25
3 21 70 70 70 70 70 50 50 50 50 50 50 50 30 30 0 0 0 20 20 20 40 0 0 0 0
4 19 40 40 40 40 60 60 60 0 0 0 50 50 50 50 50 50 65 65 65 0 0 0 0 0 0
5 15 15 15 15 15 15 25 25 25 25 25 25 10 10 10 10 0 0 0 0 0 0 0 0 0 0
6 25 80 80 80 80 80 80 80 50 50 50 50 0 0 0 0 0 50 50 50 90 90 90 90 90 90
7 22 25 25 25 40 40 40 40 40 65 65 65 65 65 65 65 0 0 0 0 40 40 40 0 0 0

 

I want to know what their dose trend was. Basically, if I was doing this task manually I would make a plot for each person with x being 1 to i where i=Total_days and y being the amount of drug received on that day (Total_dose[i]) and then I would fit a trendline on that plot. My goal is to have a variable "slope" that is "Pos" if the slope of the trend line is positive "Neg" if the slope is negative and "Zero" in the unlikely case that the slope is actually zero.

 

Does anyone know how can this be done in SAS 9.4 TS?

 

Many thanks,

 

 

 

 

 

 

1 REPLY 1
PaigeMiller
Diamond | Level 26

First, you would run PROC TRANSPOSE to create a long data set, rather than a wide data set. Then turn the zeros into missing. Lastly, run regressions or estimate trends with a BY ID; statement.

 

Here's the PROC TRANSPOSE part and the turning zeros into missing part

 

proc transpose data=have out=t;
    by id;
    var dose_day:;
run;
data t1;
    set t;
    if col1=0 then col1=.;
    day=input(substr(_name_,9),3.);
run;
--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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