|
something like ...
data ;
set or read your file ;
array countvars {*} var1--var? ;
new= 0 ;
do i=1 to dim(countvars) ;
new = new + (countvars(i)=1 or counter(i)=2) ;
end ;
run ;
syntax probably not exactly right ..
Don
Annette wrote:
>
> dear SAS list,
> I have a data set in the following structure:
> VAR1 VAR2 VAR3 VAR4
> 1 5 3 1
> 3 2 3 3
> 4 5 1 3
> All I want to do is to count the freqs of 1s and 2s in a row, and to add
> their sum in a var NEW
> VAR1 VAR2 VAR3 VAR4 NEW (sum of 1s and 2's in VAR1 to VAR4)
> 1 5 3 1 2
> 3 2 3 3 1
> 3 4 8 7 0
> 4 5 1 2 2
> The real dataset contains dozends of vars.
> Your help is greatly appreciated!
> Annette
--
Don Stanley, B.SC, Dip O.R.S, MNZCS
EMAIL:: don_stanley@xtra.co.nz, don@sysware.co.nz
Author:: Beyond the obvious with SAS Screen Control Language.
Author:: Solutions for your GUI Applications Development Using SAS/AF
FRAME Technology
http://www.sysware.co.nz ,
http://www.geocities.com/don_stanley_nz/don_home.htm
|