BookmarkSubscribeRSS Feed
nadream23
Calcite | Level 5

Have: 

DateTimeSample no.WBC(10^3/uL)
5/12/202017:57:46            01a1
5/12/202017:58:52           01a2
5/13/20202:00:48            01a3
5/13/20202:01:43            01a4
               

 

Want:

DateTimeSample no.Time PointWBC(10^3/uL)WBC avg (based on time point) 
5/12/202017:57:46            01aBase11+2/2
5/12/202017:58:52           01aBase2 
5/13/20202:00:48            01a8 Hour33+4/2
5/13/20202:01:43            01a8 Hour4 

 

I am attempting to create a column that is able to identify the following: earliest and second earliest time points, latest/second latest time pints, AND time points in the middle as well. 

 

Then using these time points, find the mean of a number of variables (such as WBC).  For ex: WBC average for the base would be 1+2, where base represents the earliest and second earliest times. 

2 REPLIES 2
ballardw
Super User

I don't see anything in that want that identifies "earliest and second earliest time points, latest/second latest time pints" (sic).

 

What I think you may be expecting will require example data in the form of a data step to test code and since you have DATES in a separate variable explain how that is used as well. The example data is because if your data does not have a datetime value then this is likely doomed.

 

Also, do you expect this to be a running process (hard to tell with only 4 values when you are asking about using 4 of them at least)? If so, then a longer example data set may be needed. Especially with " AND time points in the middle as well. " Which seems to imply way more than 4 values. 

 

What is the role of the variable Sample_no? Is this process supposed to applied separately within sample_no values?

 

Now, walk us through what you think "1 +2/2" means by pointing out exactly which values are used. I'm a mathematician and "1 + 2/2" = 2.

nadream23
Calcite | Level 5

I'm sorry this is my first post.

Base refers to the earliest and second earliest time points.

Sample No is needed because this process will be done for a number of samples.

WBC average: I want this variable to average out the earliest and second earliest WBC counts for time points. So for the base time point, I want WBC avg to average out WBC counts of 5/12/2020 17:57:46 (which is 1) AND 5/12/2020 17:58:52 (which is 2) . And WBC average for 8 hour: the average would be 3 + 4 / 2 (3 from 5/13/2020 2:00:48 AND 4 from 5/13/2020 2:01:43)
Here is a bigger dataset. And yes, I would need the process for a number of observations.

Have:
Date Time Sample no. WBC(10^3/uL)
5/2/2020 17:57:46 1a 7
5/2/2020 17:58:52 1a 6
5/3/2020 2:00:48 1a 10
5/3/2020 2:01:43 1a 4
5/3/2020 6:00:41 1a 6
5/3/2020 6:01:34 1a 6
5/3/2020 18:00:46 1a 6.8
5/3/2020 18:01:40 1a 6.91
5/3/2020 18:58:22 1a 6.6
5/3/2020 18:59:15 1a 6.4

WANT

Date Time Sample no. WBC(10^3/uL) Average Time Point
5/2/2020 17:57:46 1 7 (7 + 6) / 2 Base
5/2/2020 17:58:52 1 6 -- Base

5/3/2020 2:00:48 1 10 (10+4/2) 8 Hour
5/3/2020 2:01:43 1 4 -- 8 Hour

5/3/2020 6:00:41 1 6 (6+6)/2 12 Hour
5/3/2020 6:01:34 1 6 -- 12 Hour

5/3/2020 18:00:46 1 6.8 (6.8+6.91)/2 24 Hour
5/3/2020 18:01:40 1 6.91 24 Hour

5/3/2020 18:58:22 1 6.6 25 Hour
5/3/2020 18:59:15 1 6.4 25 Hour

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 442 views
  • 0 likes
  • 2 in conversation