Friday
NewUsrStat
Lapis Lazuli | Level 10
Member since
03-18-2017
- 264 Posts
- 105 Likes Given
- 0 Solutions
- 2 Likes Received
-
Latest posts by NewUsrStat
Subject Views Posted 667 Thursday 720 Thursday 504 2 weeks ago 553 2 weeks ago 569 2 weeks ago 484 03-11-2025 01:30 PM 1015 02-07-2025 06:14 AM 1079 02-07-2025 03:43 AM 1008 02-06-2025 12:28 PM 1110 02-06-2025 11:01 AM -
Activity Feed for NewUsrStat
- Liked Re: Remove duplicated records based on the comparison of two dates for Ksharp. Friday
- Posted Re: Remove duplicated records based on the comparison of two dates on New SAS User. Thursday
- Posted Remove duplicated records based on the comparison of two dates on New SAS User. Thursday
- Got a Like for Assign events to weeks of year. a week ago
- Posted Re: Assign events to weeks of year on New SAS User. 2 weeks ago
- Posted Re: Assign events to weeks of year on New SAS User. 2 weeks ago
- Posted Assign events to weeks of year on New SAS User. 2 weeks ago
- Posted Join a table with another in long format by two variables on New SAS User. 03-11-2025 01:30 PM
- Liked Re: Transform a dataset from long to wide format and fill values for Patrick. 02-07-2025 01:01 PM
- Posted Re: Transform a dataset from long to wide format and fill values on New SAS User. 02-07-2025 06:14 AM
- Posted Transform a dataset from long to wide format and fill values on New SAS User. 02-07-2025 03:43 AM
- Liked Re: Add a value between two values of a variable for Tom. 02-06-2025 12:29 PM
- Posted Re: Add a value between two values of a variable on New SAS User. 02-06-2025 12:28 PM
- Posted Re: Add a value between two values of a variable on New SAS User. 02-06-2025 11:01 AM
- Posted Add a value between two values of a variable on New SAS User. 02-06-2025 10:48 AM
- Liked Re: Set a rule where never a value different from 0 or missing appears for FreelanceReinh. 02-06-2025 09:31 AM
- Posted Re: Set a rule where never a value different from 0 or missing appears on New SAS User. 02-06-2025 09:15 AM
- Posted Set a rule where never a value different from 0 or missing appears on New SAS User. 02-06-2025 08:52 AM
- Liked Re: Subtract exactly one year from a date for FreelanceReinh. 02-06-2025 08:39 AM
- Posted Subtract exactly one year from a date on New SAS User. 02-06-2025 04:42 AM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 1 4 1 -
My Liked Posts
Subject Likes Posted 1 2 weeks ago 1 03-06-2024 11:23 AM
Thursday
Thank you for your help. Unfortunately there are also cases where admission=discharge and no other admissions occur for that patient. The way you suggest would remove that cases.
... View more
Thursday
Dear all,
suppose to have the following:
data DB;
input ID :$20. Admission :date09. Discharge :date09.;
format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 13JAN2015
0001 13JAN2015 31MAR2015
0001 01MAR2018 30SEP2018
0001 01JAN2019 31DEC2019
0002 01JAN2015 31DEC2015
0002 01JAN2019 01JAN2019
0002 01JAN2019 15APR2019
;
Is there a way to get the following?
data DB1;
input ID :$20. Admission :date09. Discharge :date09.;
format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 31MAR2015
0001 01MAR2018 30SEP2018
0001 01JAN2019 31DEC2019
0002 01JAN2015 31DEC2015
0002 01JAN2019 15APR2019
;
In other words for equal admission dates I would like to remove the rows where admission == discharge and retain all the cases where admission =! discharge. The first case occurs because there is an emergency department access while the second is a real admission.
Can anyone help me please?
Best
... View more
2 weeks ago
Yes, what I need is to "annotate" the week of the admission and not the stay. Index means that there was an admission in that week. DB1 contains only the calendar weeks where there was at least one admission based on DB. i will add the desired output.
... View more
2 weeks ago
Exactly. I just need to put the admission in the calendar week where it occurred. The problem here is that although the patient 0005 has not a new admission but he/she simply stay in hospital it is counted as a new admission.
... View more
2 weeks ago
1 Like
Hi guys,
suppose to have the following two datasets:
data DB;
input ID :$20. Admission :date09. Discharge :date09.;
format Admission date9. Discharge date9.;
cards;
0001 04FEB2017 22FEB2017
0002 10JUN2017 16JUN2017
0004 29NOV2017 01DEC2017
0005 28DEC2017 05JAN2018
;
and
data DB1;
input Start :date09. End :date09. Index;
format Start :date9. End :date9.;
cards;
29JAN2017 04FEB2017 1
04JUN2017 10JUN2017 1
26NOV2017 02DEC2017 1
24DEC2017 30DEC2017 1
31DEC2017 06JAN2018 1
;
Desired output:
data DBx;
input Start :date09. End :date09. Index;
format Start :date9. End :date9.;
cards;
29JAN2017 04FEB2017 1
04JUN2017 10JUN2017 1
26NOV2017 02DEC2017 1
24DEC2017 30DEC2017 1
;
The DB dataset contains a set of admissions with relative date of admission and date of discharge. The duration of the admission is not strictly one week but the time the patient needs.
The DB1 dataset (a small par is reported for simplicity) contains the week (Start-End) of the year where the admission occurred (referring to "Admission" variable of DB). For example, for ID 0001 the admission occurred at 04FEB2017 that is in the week 29JAN2017-04FEB2017 of year 2017.
The problem is with ID = 0005 because two weeks are counted in DB1 but no new admission occurred for ID 0005. The patient only stayed hospitalized. The count should be 0.
Here the code used to generate DB1:
%macro Counts(dataset);
data &dataset;
set &dataset;
week_begin = intnx('week', Admission, 0);
format week_begin date9.;
run;
proc freq data=&dataset;
tables week_begin / out=admissions&dataset (keep=week_begin count rename=(count=n_&dataset)) noprint;
run;
proc sql;
create table Counts_&dataset as
select d1.*, d2.n_&dataset
from all_weeks d1 left join admissions&dataset d2
on d2.week_begin >= d1.admission and d2.week_begin <= d1.discharge
;
quit;
proc sort data = Counts_&dataset; by admission; run;
data TSM_&dataset;
set Counts_&dataset;
if missing (n_&dataset) then n_&dataset = 0;
run;
%mend;
the dataset all_weeks looks like this:
data All_weeks;
input Admission :date09. Discharge :date09.;
format Admission date9. Discharge date9.;
cards;
29DEC2013 04JAN2014
05JAN2014 11JAN2014
12JAN2014 18JAN2014
19JAN2014 25JAN2014
26JAN2014 01FEB2014
.....
;
Can anyone help me please?
Thank you in advance
... View more
03-11-2025
01:30 PM
Hi guys,
suppose to have the following dataset:
data DB;
input Admission :date09. week :$20. Count_path1 Count_path2;
format Admission date9.;
cards;
06JUL2014 28w2014 0 21
13JUL2014 29w2014 1 56
20JUL2014 30w2014 0 0
27JUL2014 31w2014 3 1
03AUG2014 32w2014 4 4
10AUG2014 33w2014 0 0
;
and another one:
data DB1;
input week :$20. Pathogen :$20. Value; ;
cards;
28w2014 path1 23
29w2014 path1 1
30w2014 path2 56
31w2014 path1 67
32w2014 path2 6
33w2014 path2 2
;
Is there a way to get the following?
data DB3;
input Admission :date09. week :$20. Count_path1 Count_path2 path1 path2;
format Admission date9.;
cards;
06JUL2014 28w2014 0 21 23 0
13JUL2014 29w2014 1 56 1 0
20JUL2014 30w2014 0 0 0 56
27JUL2014 31w2014 3 1 67 0
03AUG2014 32w2014 4 4 0 6
10AUG2014 33w2014 0 0 0 2
;
In other words I would like to join the two tables at week and pathogen variables.
Thank you in advance
... View more
02-07-2025
06:14 AM
Really really sorry: for ID 0001 age class 3 = 1.4 while age_class = 2 is 5. I will edit my question soon.
... View more
02-07-2025
03:43 AM
Hi guys,
suppose to have the following table:
data DB;
input ID :$20. Admission :date09. Discharge :date09. Age_class Age_end Index Value Total;
format Admission date9. Discharge date9.;
cards;
0001 01JUL2014 16AUG2014 1 4 1 2.3 11.9
0001 13MAY2018 22JUN2018 3 4 0 1.4 .
0001 23JAN2019 25JAN2019 4 4 0 3.2 .
0002 13MAY2016 22SEP2016 1 5 1 2 7.9
0002 09JUL2023 10JUL2023 2 5 0 0.3 .
0002 12SEP2024 15SEP2024 3 5 0 0.2 .
0003 01JUL2014 18AUG2014 1 3 1 12 17.3
0003 07DEC2023 16DEC2023 2 3 0 0.3 .
0004 12JAN2014 15JAN2014 1 2 1 2 2.1
0004 30MAY2019 13JUL2019 2 2 0 0.1 .
0005 30JUN2019 13OCT2019 5 5 0 4.1 .
;
run;
Is there a way to get the following?
data DB1;
input ID :$20. Admission :date09. Discharge :date09. Age_class Age_end Index Value Total Age_class1 Age_class2 Age_class3 Age_class4 Age_class5;
format Admission date9. Discharge date9.;
cards;
0001 01JUL2014 16AUG2014 1 4 1 2.3 11.9 2.3 5 1.4 3.2 .
0001 13MAY2018 22JUN2018 3 4 0 1.4 . . . . . .
0001 23JAN2019 25JAN2019 4 4 0 3.2 . . . . . .
0002 13MAY2016 22SEP2016 1 5 1 2 7.9 2 0.3 0.2 5 0.4
0002 09JUL2023 10JUL2023 2 5 0 0.3 . . . . . .
0002 12SEP2024 15SEP2024 3 5 0 0.2 . . . . . .
0003 01JUL2014 18AUG2014 1 3 1 12 17.3 12 0.3 5 . .
0003 07DEC2023 16DEC2023 2 3 0 0.3 . . . . . .
0004 12JAN2014 15JAN2014 1 2 1 2 2.1 2 0.1 . . .
0004 30MAY2019 13JUL2019 2 2 0 0.1 . . . . . .
0005 30JUN2019 13OCT2019 5 5 1 4.1 4.1 . . . . 4.1
;
run;
In other words, for each ID in DB there is the Age_class at each admission and an Age_class at exit (Age_end) from the study. Then, there is the "Value" variable that is the time the patient stay in the corresponding Age_class (before exit). There is also a "Total" time in the study. What I need is to transform the dataset DB into a wide format where there are columns corresponding to the age classes filled by the corresponding Value. Note that in this new dataset the row-wise total must be reached and must be equal to "Total" and so: if there is a jump in the age classes (Age_class variable) a value = 5 years must be added because the age-class interval is of max 5 years.
Finally, in the new wide dataset (DB1) rows must be filled only where Index = 1
Can anyone help me please?
Thank you very much in advance
... View more
02-06-2025
12:28 PM
Thank you very much Tom for your help as usual. But it does not work correctly because it is mandatory that mydate1 also should not be missed. In other words mydate2 is missing between TWO not missing values.
... View more
02-06-2025
10:48 AM
Hi guys,
suppose to have the following:
data DB;
input ID :$20. Var1: $20. Value1;
cards;
0001 Mydate1 2
0001 Mydate2 .
0002 Mydate1 .
0002 Mydate2 4
0003 Mydate1 2
0003 Mydate2 .
0003 Mydate3 6
0003 Mydate4 .
0003 Mydate5 0
run;
Is there a way to add a number = 5 every time, for each ID Mydate1 is not missing as Mydate3 while Mydate 2 is missing?
Desired output:
data DB1;
input ID :$20. Var1: $20. Value1;
cards;
0001 Mydate1 2
0001 Mydate2 .
0002 Mydate1 .
0002 Mydate2 4
0003 Mydate1 2
0003 Mydate2 5
0003 Mydate3 6
0003 Mydate4 .
0003 Mydate5 0
run;
Rule: for each ID if not missing (Mydate1) and not missing(Mydate3) and missing(Mydate2) then Mydate2 = 5.
Thank you in advance
... View more
02-06-2025
09:15 AM
Just edited. What I don't know how to say is: when there is never a number (^=0) and conversely when there are always missing or 0s then...do something
... View more
02-06-2025
08:52 AM
Hi guys,
suppose to have the following:
data DB;
input ID :$20. Var1: $20. Value1 Value2;
cards;
0001 Mydate1 . .
0001 Mydate2 3.4 3.4
0002 Mydate1 . .
0002 Mydate2 3 3
0003 Mydate1 . .
0003 Mydate2 . .
0003 Mydate3 . .
0003 Mydate4 . .
0003 Mydate5 0 3.4
run;
I would say the following:
if for each ID value 1 is always missing (for every Mydate*) or 0 (i.e., never a number different from 0 or not missing) then where Value1 = 0 then Value1 = Value2.
Desired output:
data DB1;
input ID :$20. Var1: $20. Value1 Value2;
cards;
0001 Mydate1 . .
0001 Mydate2 3.4 3.4
0002 Mydate1 . .
0002 Mydate2 3 3
0003 Mydate1 . .
0003 Mydate2 . .
0003 Mydate3 . .
0003 Mydate4 . .
0003 Mydate5 3.4 3.4
run;
Can you help me please?
... View more
02-06-2025
04:42 AM
Hi guys, I have a date like this: 01JUL2021. How can I get 01JUL2020? I need to subtract exactly one year.
I tried the following but without success. The date is no more "01JUL"
my_new_date = INTNX('YEAR',mydate,-1);
Thank you in advance
Best
... View more
01-17-2025
12:17 PM
Because 3.4 is a duplicated value.
... View more