BookmarkSubscribeRSS Feed
sufianbadar
Calcite | Level 5

To find out the non missing values of any particular variable at any particular position with conditional statement like it should be greater than or less than

SUB VISIT SBP DBP WEIGH

  

10001112911059
10001214010657
100013

55
10001416410054
100015
9256
10002115610382
100022

80
100023

81
1000241289279
100025134
81
1000311617890
100032

88
100033
8587
100034139
89
1000351207791
10004113410587
100042

85
1000431609886
1000441398889
100045
7790
10005114710298
100052
9596
100053
10099
10005415097100
1000551438598
100061139
94
100062128
90
1000631358593
100064

95
100065
7991


1. Get only latest non-missing values from on or before 3 visit into 3 different data sets for DBP, SBP and Weight variables. I am not able to put questions in wright words.

2. Merge all three, SBP, DBP, WEIGHT

I appreciate if you guide me how to write the code. I am expecting this answer, which is marked in red color.


Thanks.

3 REPLIES 3
Ksharp
Super User

Hard to understand you .  Subject 10003 's weight 87 should not mark as red ?

Suppose I know what you mean.

data have;
input SUB VISIT SBP DBP WEIGH ;
cards;
10001     1     129     110     59
10001     2     140     106     57
10001     3     . . 55
10001     4     164     100     54
10001     5     . 92     56
10002     1     156     103     82
10002     2     . . 80
10002     3     . . 81
10002     4     128     92     79
10002     5     134      . 81
;
run;
data want;
 set have;
 by sub;
 retain s d w found;
 if first.sub then do;found=0;n=0;end;
 if not missing(sbp) and not missing(dbp) and not found then do;s=sbp;d=dbp;end;
 if not missing(weigh) and not found then w=weigh;
 n+1;
 if n gt 2 then found=1;
 if last.sub;
 keep sub s d w ;
run;

Xia Keshan

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 654 views
  • 0 likes
  • 4 in conversation