c****o 发帖数: 69 | 1 COME ACROSS A PROBLEM DURING WORK.....
SAS DATA SET ARE LIKE:
Name Test1 ..... Test1000
Billy 1 2
.....
....
Actually for all the Test Variable, there are only 3 results: 1,2,3
My question is: how to compute the percentage of each outcome in each Test1
and saved it as the last line in the data set?
For example: For Test1, I want to know the percentage of value=1 in the
total observations (by the way, there are missing values in each Test and I
don't want to include the missing v |
a********s 发帖数: 188 | 2 I do not know exactly what PROC can be used in SAS. But why do not you try
to use PROC FREQ for all variables and save the count number (eg. value=1
for test1) to new data sets. Then, calculate the percentage. GL. |
y****n 发帖数: 46 | 3 %macro tt;
data old;
length name $20;
do j=1 to 1000;
name=catx('_','xx',j);
%do i=1 %to 100;
test&i=mod(floor(ranuni(2)*1000),3)+1;
%end;
output;
end;
drop j;
run;
%mend;
%tt;
data new;
array tt(100) test1-test100;
array ct1(100);
array ct2(100);
array ct3(100);
set old end=eof;
do i=1 to 100;
if tt(i)=1 then ct1(i)+1;
if tt(i)=2 then ct2(i)+1;
if tt(i)=3 then ct3(i)+1;
end;
|
c****o 发帖数: 69 | 4 Thanks a lot!!
【在 y****n 的大作中提到】 : %macro tt; : data old; : length name $20; : do j=1 to 1000; : name=catx('_','xx',j); : %do i=1 %to 100; : test&i=mod(floor(ranuni(2)*1000),3)+1; : %end; : output; : end;
|
c****o 发帖数: 69 | 5 I did tried actually. but am wondering whether there is a easier way...
thanks
【在 a********s 的大作中提到】 : I do not know exactly what PROC can be used in SAS. But why do not you try : to use PROC FREQ for all variables and save the count number (eg. value=1 : for test1) to new data sets. Then, calculate the percentage. GL.
|