BookmarkSubscribeRSS Feed
Gregorytus07
Fluorite | Level 6

Hi everyone,

 

I have a dataset containing four datetime variables (RGL_time, RPH_time, RAGAP_time, and RBCARB_time), each indicating when corresponding values (glucose, pH, AGAP, and Bcarb) were resolved. The overall resolution time is determined by the earliest point when glucose and any two other values have been resolved. For instance, if glucose was resolved at 10 am, pH at 2 pm, AGAP at 4 pm, and BCARB at 6 pm on the same day, the overall resolution time would be 4 pm. This is because 4 pm is the earliest time when glucose and any two additional values have been resolved. However, if pH resolved at 2 pm, AGAP at 4 pm, BCARB at 6 pm, and glucose at 8 pm on the same day, the overall resolution time would be 8 pm. This is because glucose must always be included in the values that have resolved. 

 

I have attached a sample dataset for additional insight into the dataset.

 

Thanks for your help.

5 REPLIES 5
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 </> icon or attached as text to show exactly what you have and that we can test code against.

 

I read your description a few times and I can't derive actual programmable rules, partially because I can't open XLSX from unknown sources. Examples without rules are very hard to program. Especially with something like medical tests that may be done at all hours. What happens when some of these are performed at 10 or 11 PM and the remainders at 12 or 01 AM? Is the calendar date the "day" for same day purposes?

Are any of these tests repeated on a given "day" (again consider midnight in the discussion).

How do we know if something is resolved (again, I can't look at your spreadsheet to make a guess)?

Gregorytus07
Fluorite | Level 6

@ballardw Thanks for your feedback.

The dataset only contains the first recorded value and the corresponding date and time when each of the lab tests met the criteria for resolution. This is a screenshot of the sample dataset for additional context.

 

Gregorytus07_0-1710367601534.png

 

Thanks for your help.

ballardw
Super User

Since your very first observation has the issue about different calendar dates already asked about for clarification you do have to provide some sort of rule(s) that are used to define "day" with the way you described your need.

 

Also, I don't see anything related to patient identity so have to assume that each observation of the data set is treated on its own.

Gregorytus07
Fluorite | Level 6

@ballardw Yes, each study_id has only one row of data. For example: study ID 1 had glucose value resolved on 2/28/17 at 7 pm, while its AGAP and Bcarb resolved on 2/27/17 at 7 pm. Therefore, the overall resolution time would be 2/28/17 at 7 pm. Because the overall resolution time is determined by the earliest point when glucose and any two other values have resolved. 

Tom
Super User Tom
Super User

I don't understand what is difficult about this.  Perhaps I have the wrong impression about what your variables mean?

 

You appear to have 4 datetime variables.

You appear to want the MAX of the GLUCOSE datetime and 2nd smallest other datetime .

want = max(glucose,smallest(2,of testA testb testc));

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
  • 5 replies
  • 920 views
  • 0 likes
  • 3 in conversation