BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jomag
Obsidian | Level 7

Hello!

 

I have a data set that measures the height of patients at different time points and their pulmonary function at one particular time point. I was not given the dates of the measurements as they are PHI. My task is to obtain the height that is measured as close to the pulmonary function test day as possible. I am not sure how to do this without complicating. Can you please help me? Thanks in advance.

 

Height - Height in cm

Ht_days = Date of diagnosis - clinical visit date

Pulm_testday = Date of diagnosis - Pulmonary function test date

Diff_days = Ht_days - Pulm_testday

 

Here's an excerpt of the data set:

IDHeightHt_daysPulm_testdayDiff_days
117063135627-686
117163695627-742
117262485627-621
117347075627920
117447565627871
117548305627797
117648935627734
215034133060-353
2150.234203060-360
2150.334373060-377
215235423060-482
31696259634283
31706306634236
3170.3634263420
317263486342-6
317264046342-62

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Do you care if its before or after?

 

  1. If not, make the diff_days an absolute value instead of negative and positive.
  2. Sort by ID and diff_days
  3. Keep or flag the first record which will be the minimum. 

@jomag wrote:

Hello!

 

I have a data set that measures the height of patients at different time points and their pulmonary function at one particular time point. I was not given the dates of the measurements as they are PHI. My task is to obtain the height that is measured as close to the pulmonary function test day as possible. I am not sure how to do this without complicating. Can you please help me? Thanks in advance.

 

Height - Height in cm

Ht_days = Date of diagnosis - clinical visit date

Pulm_testday = Date of diagnosis - Pulmonary function test date

Diff_days = Ht_days - Pulm_testday

 

Here's an excerpt of the data set:

ID Height Ht_days Pulm_testday Diff_days
1 170 6313 5627 -686
1 171 6369 5627 -742
1 172 6248 5627 -621
1 173 4707 5627 920
1 174 4756 5627 871
1 175 4830 5627 797
1 176 4893 5627 734
2 150 3413 3060 -353
2 150.2 3420 3060 -360
2 150.3 3437 3060 -377
2 152 3542 3060 -482
3 169 6259 6342 83
3 170 6306 6342 36
3 170.3 6342 6342 0
3 172 6348 6342 -6
3 172 6404 6342 -62

 


 

 

 

View solution in original post

7 REPLIES 7
Reeza
Super User

Do you care if its before or after?

 

  1. If not, make the diff_days an absolute value instead of negative and positive.
  2. Sort by ID and diff_days
  3. Keep or flag the first record which will be the minimum. 

@jomag wrote:

Hello!

 

I have a data set that measures the height of patients at different time points and their pulmonary function at one particular time point. I was not given the dates of the measurements as they are PHI. My task is to obtain the height that is measured as close to the pulmonary function test day as possible. I am not sure how to do this without complicating. Can you please help me? Thanks in advance.

 

Height - Height in cm

Ht_days = Date of diagnosis - clinical visit date

Pulm_testday = Date of diagnosis - Pulmonary function test date

Diff_days = Ht_days - Pulm_testday

 

Here's an excerpt of the data set:

ID Height Ht_days Pulm_testday Diff_days
1 170 6313 5627 -686
1 171 6369 5627 -742
1 172 6248 5627 -621
1 173 4707 5627 920
1 174 4756 5627 871
1 175 4830 5627 797
1 176 4893 5627 734
2 150 3413 3060 -353
2 150.2 3420 3060 -360
2 150.3 3437 3060 -377
2 152 3542 3060 -482
3 169 6259 6342 83
3 170 6306 6342 36
3 170.3 6342 6342 0
3 172 6348 6342 -6
3 172 6404 6342 -62

 


 

 

 

jomag
Obsidian | Level 7
Thanks, Reeza! You always come through for me!
novinosrin
Tourmaline | Level 20
data have;;
input ID	Height	Ht_days	Pulm_testday	Diff_days;
datalines;
1	170	6313	5627	-686
1	171	6369	5627	-742
1	172	6248	5627	-621
1	173	4707	5627	920
1	174	4756	5627	871
1	175	4830	5627	797
1	176	4893	5627	734
2	150	3413	3060	-353
2	150.2	3420	3060	-360
2	150.3	3437	3060	-377
2	152	3542	3060	-482
3	169	6259	6342	83
3	170	6306	6342	36
3	170.3	6342	6342	0
3	172	6348	6342	-6
3	172	6404	6342	-62
;

proc sql;
create table want as
select *
from have
group by id
having abs(diff_days)=min(abs(Diff_days));
quit;

@jomag If i understand you correctly, You have done most of the work actually, mine is just a finishing touch

jomag
Obsidian | Level 7
Thanks, novinosrin! That works too.

I used the following code:

proc means data=one max min maxdec=1;
class study_id;
var diff_day;
output out=min_ht;
run;

data min_ht1;
set min_ht;
where _STAT_ = 'MIN';
drop _TYPE_ _FREQ_ _STAT_;
run;
jomag
Obsidian | Level 7
I took the absolute value of the difference and then ran proc means.
ballardw
Super User

@jomag wrote:

Hello!

 

I have a data set that measures the height of patients at different time points and their pulmonary function at one particular time point. I was not given the dates of the measurements as they are PHI. My task is to obtain the height that is measured as close to the pulmonary function test day as possible. I am not sure how to do this without complicating. Can you please help me? Thanks in advance.

 

Height - Height in cm

Ht_days = Date of diagnosis - clinical visit date

Pulm_testday = Date of diagnosis - Pulmonary function test date

Diff_days = Ht_days - Pulm_testday

 

Here's an excerpt of the data set:

ID Height Ht_days Pulm_testday Diff_days
1 170 6313 5627 -686
1 171 6369 5627 -742
1 172 6248 5627 -621
1 173 4707 5627 920
1 174 4756 5627 871
1 175 4830 5627 797
1 176 4893 5627 734
2 150 3413 3060 -353
2 150.2 3420 3060 -360
2 150.3 3437 3060 -377
2 152 3542 3060 -482
3 169 6259 6342 83
3 170 6306 6342 36
3 170.3 6342 6342 0
3 172 6348 6342 -6
3 172 6404 6342 -62

 


Do you have the date of diagnosis. You say explicitly that the dates of measurement are PHI but not if the diagnosis was.

If so merge the diagnosis date and apply some simple algebra to get:

clinical visit date = date of diagnosis - Ht_days

jomag
Obsidian | Level 7
All dates are PHI, unfortunately. I missed to mention that in my question.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 959 views
  • 3 likes
  • 4 in conversation