09-10-2021
corkee
Calcite | Level 5
Member since
01-10-2017
- 40 Posts
- 0 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by corkee
Subject Views Posted 1081 04-08-2020 04:05 PM 1090 04-08-2020 03:54 PM 2870 11-22-2019 01:09 PM 2874 11-22-2019 01:05 PM 2885 11-22-2019 12:56 PM 5451 09-11-2019 01:22 PM 5460 09-11-2019 01:15 PM 5469 09-11-2019 01:09 PM 5479 09-11-2019 01:01 PM 5499 09-11-2019 12:44 PM -
Activity Feed for corkee
- Posted Re: Selecting first observation based on multiple keys on SAS Programming. 04-08-2020 04:05 PM
- Posted Selecting first observation based on multiple keys on SAS Programming. 04-08-2020 03:54 PM
- Posted Re: Check if at least one variable in list is not missing on SAS Programming. 11-22-2019 01:09 PM
- Posted Re: Check if at least one variable in list is not missing on SAS Programming. 11-22-2019 01:05 PM
- Posted Check if at least one variable in list is not missing on SAS Programming. 11-22-2019 12:56 PM
- Posted Re: Removing duplicates based on two variables, but prioritizing based on a third variable on SAS Programming. 09-11-2019 01:22 PM
- Posted Re: Removing duplicates based on two variables, but prioritizing based on a third variable on SAS Programming. 09-11-2019 01:15 PM
- Posted Re: Removing duplicates based on two variables, but prioritizing based on a third variable on SAS Programming. 09-11-2019 01:09 PM
- Posted Re: Removing duplicates based on two variables, but prioritizing based on a third variable on SAS Programming. 09-11-2019 01:01 PM
- Posted Re: Removing duplicates based on two variables, but prioritizing based on a third variable on SAS Programming. 09-11-2019 12:44 PM
- Posted Removing duplicates based on two variables, but prioritizing based on a third variable on SAS Programming. 09-11-2019 12:29 PM
- Posted Re: Calculating number of hours from midnight on SAS Programming. 05-29-2018 09:54 AM
- Posted Calculating number of hours from midnight on SAS Programming. 05-29-2018 12:05 AM
- Posted Re: Finding the second minimum if observation with first minimum does not satisfy other conditions on SAS Programming. 04-05-2018 11:44 AM
- Posted Finding the second minimum if observation with first minimum does not satisfy other conditions on SAS Programming. 04-05-2018 10:42 AM
- Posted Re: Selecting rows with absolute minimum within each group on SAS Programming. 04-04-2018 06:19 PM
- Posted Re: Selecting rows with absolute minimum within each group on SAS Programming. 04-04-2018 06:15 PM
- Posted Selecting rows with absolute minimum within each group on SAS Programming. 04-04-2018 05:56 PM
- Posted Re: PROC SQL - Counting by ID on SAS Programming. 12-01-2017 11:06 AM
- Posted PROC SQL - Counting by ID on SAS Programming. 12-01-2017 10:48 AM
04-08-2020
04:05 PM
Hello! Based on what you said, it sounds exactly what I'm looking for. Thanks for the clarification!
... View more
04-08-2020
03:54 PM
Hello, I'm trying to select the first observation based on multiple BY values, using the first or last modifier. The data below are already sorted, and I really want to keep the rows that are in bold (the first column is patientID, second is episodekey, and third is visitkey). Essentially, some patientID's have multiple VISITKEY's linked to the same EPISODEKEY. For these subjects, I want to keep the unique episodes, after sorting the data appropriately. This is the code I've used to sort the data: proc sort data=fix2; by ncdrpatientid episodekey visitkey descending died_yn descending f_assessmentdate descending dcdate descending tvtprocedurestopdate; run; I'm not sure if this works. Can anyone provide some guidance? data fix_final;
set fix2;
by ncdrpatientid episodekey visitkey descending died_yn descending f_assessmentdate descending dcdate descending tvtprocedurestopdate;
if first.episodekey;
run; 3762722 132066 130260 05JUL2017 Alive 29JUN2017 29JUN2017 09JUL2018 . Alive . 0 2 3762722 132066 130260 05JUL2017 Alive 29JUN2017 29JUN2017 08AUG2017 . Alive . 0 2 3762722 132066 130265 05JUL2017 Alive 30JUN2017 30JUN2017 09JUL2018 . Alive . 0 2 3762722 132066 130265 05JUL2017 Alive 30JUN2017 30JUN2017 08AUG2017 . Alive . 0 2 3762722 64600 63607 17JAN2016 Alive 15JAN2016 15JAN2016 23JAN2017 . Alive . 0 2 3762722 64600 63607 17JAN2016 Alive 15JAN2016 15JAN2016 29FEB2016 . Alive . 0 2
... View more
11-22-2019
01:09 PM
This worked perfectly. Thank you!
... View more
11-22-2019
01:05 PM
Hi, this seems like a great idea, but my variables are not numeric. 😞
... View more
11-22-2019
12:56 PM
Hi, I have a long list of variables, code_1-code_170. I know the cmiss and nmiss functions can help you check whether the entire list of variables is missing, but is it possible to check if at least one variable in the list is NOT missing? For example, if code_1 to code_4 are not missing but the rest are, then do... If code_1 to code_169 are not missing but code_170 is, then do... I'm not sure if there's an easy way to do this.
... View more
09-11-2019
01:22 PM
Thank you @Tom and @novinosrin! You guys are great!
... View more
09-11-2019
01:15 PM
Hi @novinosrin and @Tom, both of your solutions worked and were actually what I had in mind at first. However, I was a bit hesitant because I wasn't sure if if first.index_date would remove just ANY duplicates of index_date. For example, ID index_date priority
1 1/2/19 1
2 1/2/19 0 I wouldn't want either rows to be removed, since the ID's are different, even though the index_date's are the same. Could you confirm this is the case? Thanks so much.
... View more
09-11-2019
01:09 PM
Hi @novinosrin, I have another variable that determines whether priority is = 1 or 0. I have to keep this variable for later uses. Thanks again!
... View more
09-11-2019
01:01 PM
Hi @novinosrin, I just tried your code, and unfortunately it did not give me the desired output. Hi @novinosrin, That code didn't work, unfortunately. Let me try to provide a more concrete example: ID index_date priority
1 2/3/18 0
1 2/3/18 1
1 2/3/18 0
2 3/4/15 0
3 7/14/14 0
3 7/14/14 0
4 10/1/17 1 The desired dataset would keep the 2nd, 4th, 5th (or 6th, but not both), and the last row. The code you had provided kept both the 5th and the 6th rows. Thanks for your help! Edit: I think adding another code chunk would do the trick. proc sort data=want out=want2 nodupkey;
by id index_date;
run;
... View more
09-11-2019
12:44 PM
Hi, novinosrin. No, I don't want to ONLY keep observations where priority = 1. There might be non-duplicates where priority = 0, and I want to keep those too. I just want to make sure that for duplicates, the ones where priority = 1 is kept. Thanks!
... View more
09-11-2019
12:29 PM
Hi, I'm trying to remove duplicates based on two variables: ID and index_date. I know one could easily use the following code to do this: proc sort data=dsn nodupkey;
by id index_date;
run; However, for rows with duplicates of ID and index_date, I want prioritize one row over the others. For example, my dataset looks like this: ID index_date priority
1 1/4/18 0
1 1/4/18 1
1 1/4/18 0 I want to keep the row where priority = 1 and remove the ones priority = 0. How can I do this? Would sorting my data on ID, index_date, and descending priority first and then sorting by ID and index_date with nodupkey work? Thanks!
... View more
05-29-2018
09:54 AM
Thank you, everyone. I figured out something similar to one of the proposed solutions--thankfully they match up! proc sql;
create table survey as
select participant_id,
fallaslp,
fallaslpampm,
case
when fallaslpampm = 1 then fallaslp/3600
when fallaslpampm = 2 then (fallaslp - 60*60*12)/3600
end as fallaslp_newtime
from mydata
;
quit;
... View more
05-29-2018
12:05 AM
Hi, I want to calculate the number of hours from midnight, with anything between 12 p.m. and 11:59 p.m. being negative. That is, 9 P.M. is “-3,”,while 6 A.M. is “6.” I tried the using something like the following, but I do not get the desired result. The variable I have is a time variable (12 hour clock), with another variable that indicates whether the time is in a.m. or p.m. (fallaslp_mom_v2 - 60*60*12)/3600 Any suggestions would be great. Thank you!
... View more
04-05-2018
11:44 AM
This is perfect. Thank you!
... View more
04-05-2018
10:42 AM
Hi, I am trying to extract only observations with the smallest absolute value for v1datediff. There are multiple rows of data for each unique individual, so not only do I want to extract the minimum v1datediff, but I also want to make sure that if the minimum v1datediff has missing values for another column, then I would take the next minimum with complete data. Is this doable in PROC SQL or base SAS? participant_id length absv1datediff
1 2 1
1 2.2 9
1 . 2
1 2.1 3
2 . 0
2 1.9 1
2 1.9 5 So for the above dataset, I'd like to extract, for participant 1, the first row (where length is 2). For participant 2, the minimum absv1datediff is 0 (row 5), but since it has missing length, I'd like to extract the NEXT minimum, which is row 6. I tried something like the following: proc sql;
create table v1final as
select *, abs(v1datediff) as absv1datediff, abs(ehr_height_cm - inflengthcm_v1) as measurement_diff
from visit1_merged
group by participant_id
having absv1datediff = min(absv1datediff) and length ne .
;
quit;
... View more