Hello programmers I want to do a Proc Univariate by tc tn so that i can get N Mean Std for BMI and the dichotomized heart variables (heart1-hear6). I want to present continuous variables like BMI as N Mean Std. For the heart variables , i want to do something like a/N %, where a is the number of yes's, N is the total number of non-missings and %= a/N *100 = the percentage of yes's. In the end i want something like this Study Population a/N (%) Angina xxx/xxx (xx.x%) Heartburn xxx/xxx (xx.x%) Sleepiness xxx/xxx (xx.x%) Exercise xxx/xxx (xx.x%) Palpitation xxx/xxx (xx.x%) Any xxx/xxx (xx.x%) BMI xx.x+xx.x I've attached the initial dataset and code for you to understand what i want to implement and please any help, advice or direction is appreciated. data me;
input id sex race agecat health bmi bmigroup heart1 heart2 heart3 heart4 heart5 heart6 death tc Tn $ value;
datalines;
1 0 0 5 4 22.494 2 0 1 0 0 1 1 1 1 Angina 0
1 0 0 5 4 22.494 2 0 1 0 0 1 1 1 2 Heartburn 1
1 0 0 5 4 22.494 2 0 1 0 0 1 1 1 3 Sleepiness 0
1 0 0 5 4 22.494 2 0 1 0 0 1 1 1 4 Exercise 0
1 0 0 5 4 22.494 2 0 1 0 0 1 1 1 5 Palpitation 1
1 0 0 5 4 22.494 2 0 1 0 0 1 1 1 6 Any 1
2 1 0 5 2 20.1801 1 0 0 0 1 0 1 0 1 Angina 0
2 1 0 5 2 20.1801 1 0 0 0 1 0 1 0 2 Heartburn 0
2 1 0 5 2 20.1801 1 0 0 0 1 0 1 0 3 Sleepiness 0
2 1 0 5 2 20.1801 1 0 0 0 1 0 1 0 4 Exercise 1
2 1 0 5 2 20.1801 1 0 0 0 1 0 1 0 5 Palpitation 0
2 1 0 5 2 20.1801 1 0 0 0 1 0 1 0 6 Any 1
3 1 0 4 2 26.3606 4 0 1 0 0 0 1 0 1 Angina 0
3 1 0 4 2 26.3606 4 0 1 0 0 0 1 0 2 Heartburn 1
3 1 0 4 2 26.3606 4 0 1 0 0 0 1 0 3 Sleepiness 0
3 1 0 4 2 26.3606 4 0 1 0 0 0 1 0 4 Exercise 0
3 1 0 4 2 26.3606 4 0 1 0 0 0 1 0 5 Palpitation 0
3 1 0 4 2 26.3606 4 0 1 0 0 0 1 0 6 Any 1
4 0 0 4 3 25.373 3 0 0 1 1 0 1 0 1 Angina 0
4 0 0 4 3 25.373 3 0 0 1 1 0 1 0 2 Heartburn 0
4 0 0 4 3 25.373 3 0 0 1 1 0 1 0 3 Sleepiness 1
4 0 0 4 3 25.373 3 0 0 1 1 0 1 0 4 Exercise 1
4 0 0 4 3 25.373 3 0 0 1 1 0 1 0 5 Palpitation 0
4 0 0 4 3 25.373 3 0 0 1 1 0 1 0 6 Any 1
6 0 0 4 1 24.8608 3 0 0 0 0 0 0 0 1 Angina 0
6 0 0 4 1 24.8608 3 0 0 0 0 0 0 0 2 Heartburn 0
6 0 0 4 1 24.8608 3 0 0 0 0 0 0 0 3 Sleepiness 0
6 0 0 4 1 24.8608 3 0 0 0 0 0 0 0 4 Exercise 0
6 0 0 4 1 24.8608 3 0 0 0 0 0 0 0 5 Palpitation 0
6 0 0 4 1 24.8608 3 0 0 0 0 0 0 0 6 Any 0
; run;
proc print; run;
/*format and stringing out*/
Proc format;
value testcodefm
1= 'Angina'
2= 'Heartburn'
3= 'Sleepiness'
4= 'Exercise'
5= 'Palpitation'
6= 'Any'
7= 'BMI'
;
run;
data You;
set me;
array him heart1-heart6 BMI;
do over him;
tc = _I_;
tn = put(tc,testcodefm.);
value = him;
output;
end;
keep;
run;
proc print data=you;
run;
proc univariate data= you; by tc tn;
var heart1 heart2 heart3 heart4 heart5 heart6 BMI
output out= three n=n mean=mean median=median std=std;
data four; set three;
newvar= (mean/N)* 100;
run;
proc print data= four; var newvar n;
run;
... View more