Hi all,
I would like to classify the column "status" in three categories: positive, negative and stable.
This classification is based two conditions: date and result.
Positive: for less than 30 days and positive result.
Stable: between 30 and 60 days and positive result.
Negative: more than 90 days and negative result.
I am posting the information that I have and what I am looking for.
Have | want | ||||||||
date | ID | Result | Test | date | ID | Result | Test | Status | |
1/7/2022 | A | positive | 1 | 1/7/2022 | A | positive | 1 | positive | |
11/17/2021 | A | positive | 2 | 11/17/2021 | A | positive | 2 | stable | |
12/12/2021 | A | negative | 3 | 12/12/2021 | A | negative | 3 | negative | |
1/3/2022 | B | negative | 1 | 1/3/2022 | B | negative | 1 | negative | |
5/3/2021 | B | negative | 2 | 5/3/2021 | B | negative | 2 | negative |
Thanks all,
Daniel
@Moraes86 wrote:
This classification is based two conditions: date and result.
Positive: for less than 30 days and positive result.
Stable: between 30 and 60 days and positive result.
Negative: more than 90 days and negative result.
What about other possibilities like positive more than 60 days, negative for fewer than 90 days?
Any other possible outcomes?
Please explain row 2 of your data, I don't understand the result.
Why does the date change in row 2?
How do we determine from the data if we are in the 30 day category, or the 60 day category, or the 90 day category?
My first question was "how do you calculate days". You state rules in terms of days but do not supply any obvious to me pair of dates that would be used to calculate "days" for the category assignment.
@Moraes86 wrote:
Hi all,
I would like to classify the column "status" in three categories: positive, negative and stable.
This classification is based two conditions: date and result.
Positive: for less than 30 days and positive result.
Stable: between 30 and 60 days and positive result.
Negative: more than 90 days and negative result.
I am posting the information that I have and what I am looking for.
Have want date ID Result Test date ID Result Test Status 1/7/2022 A positive 1 1/7/2022 A positive 1 positive 11/17/2021 A positive 2 11/17/2021 A positive 2 stable 12/12/2021 A negative 3 12/12/2021 A negative 3 negative 1/3/2022 B negative 1 1/3/2022 B negative 1 negative 5/3/2021 B negative 2 5/3/2021 B negative 2 negative
Thanks all,
Daniel
@Moraes86 wrote:
This is my question as well. I would like to use "today" as a reference of date. For example, today is 01/07/2022, so my question is how to use it to calculate.
If you want to use the current date and if your current date variable is actually a SAS date then this is easy:
data want; set have; days = today() - date; run;
SAS date values are numbers of days, the Today() function returns today's date as date value so subtraction works just fine to get number of days.
If your Date variable is not actually a SAS date value, as in numeric variable and from what you show some sort of mmddyy format then you want to create a date value such as with: SASdate= input(date, mmddyy10.); and use the SASdate in the comparison.
You really want a SAS date valued variable as there are a LOT of things that can be done with them.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.