Help using Base SAS procedures

How to find oud the non missing values of any particular variable at any particular position from existing table

Reply
New Contributor
Posts: 2

How to find oud the non missing values of any particular variable at any particular position from existing table

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.

Super User
Posts: 7,816

Re: How to find oud the non missing values of any particular variable at any particular position from existing table

Posted in reply to sufianbadar

Your "want" data are inconsistent; with sub 10005 you want the first dbp, although there have been measurements at every visit, so by your rule the value from visit 3 should have been chosen.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 10,035

Re: How to find oud the non missing values of any particular variable at any particular position from existing table

Posted in reply to sufianbadar

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

Respected Advisor
Posts: 3,799

Re: How to find oud the non missing values of any particular variable at any particular position from existing table

Posted in reply to sufianbadar

How is this question different from this

https://communities.sas.com/thread/74932

Ask a Question
Discussion stats
  • 3 replies
  • 203 views
  • 0 likes
  • 4 in conversation