Hello, can anyone help me?
I have some medico-administrative data and I want to create a binomial variable that will code an individual as 1, if the type of diabetes diagnosed is constant from one hospital visit to another; and code 0, if the type of diabetes diagnosed varies according to the hospital visit.
This is what my medico-administrative data looks like:
Observation (numeric) | Id (numeric) | Hospital visit Number (alphanumeric) | Type of diabetes diagnosed (numeric) |
1 | 3 | 04 | 2 |
2 | 3 | 05 | 2 |
3 | 3 | 07 | 2 |
4 | 15 | 01 | 1 |
5 | 15 | 02 | 2 |
6 | 18 | 03 | 1 |
7 | 22 | 06 | 2 |
8 | 30 | 01 | 2 |
9 | 30 | 03 | 1 |
10 | 30 | 04 | 1 |
Across all distinct hospital visits?
No, for each individual.
Can you show what you expect the result to look like?
Are the ONLY values for the diabetes variable 1 and 2?
@Wylyann wrote:
Yes, the only values for the diabetes variable are 1 (type 1 diabetes mellitus) and 2 (type 2 diabetes mellitus).
This involves writing a command that automatically creates the variable "Type of diabetes evolution" (TDevolution) that assigns code 1 to individuals (Id) "3", "18" and "22"; then code 0 to Id "15" and "30".
Still have NOT shown what the resulting data set is supposed to look like.
Maybe I didn't understand you correctly. Can you reformulate your question, please?
Read each ID twice, the first time to set a flag if there is a change in diabetes type. The second time to output data if the flag was set:
data want (drop=_:);
set have (in=firstpass) have (in=secondpass);
by id diabetes_type notsorted;
retain _keep_this_id 0;
if first.id=1 then _keep_this_id=0;
if first.id=0 and first.diabetes_type=1 then _keep_this_id=1;
if secondpass=1 and _keep_this_id=1;
run;
The first.id=0 and first.diabetes=1 condition tests for a change in diabetes others than at the beginning of the ID. Because diabetes can change up, or change down., the BY statement has the notsorted parameter.
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!
Follow along as SAS’ Robert Blanchard explains three aspects of autotuning in a deep learning context: globalized search, localized search and an in parallel method using SAS.
Find more tutorials on the SAS Users YouTube channel.