Prev: Data Step error handling
Next: UNSUBSCRIBE
From: Joe Matise on 27 Oct 2009 12:16 You could concatenate the variables together and use COUNT, if they're as simple as that: count(cats(of v:),'y') So: data example; infile datalines truncover; input id (v1 v2 v3 v4 v5) ($); cnt = count(cats(of v:),'Y'); put cnt=; datalines; 1 Y Y N Y Y 2 Y N N N N 3 Y N Y N N ;;;; run; -Joe On Tue, Oct 27, 2009 at 10:57 AM, xiao d. Liu <liuxd0603(a)yahoo.com> wrote: > Hi, anyone knows the SAS function similar to STATA "anycount"? > this is what I intend to do: > > data example: > v1 v2 v3 v4 v5 > 1Y Y N Y Y > 2Y N > 3Y N Y > > in STATA: > anycount(v1, v2, v3, v4, v5, 'Y')=4 for subject 1 > anycount(v1, v2, v3, v4, v5, 'Y')=1 for subject 2 > anycount(v1, v2, v3, v4, v5, 'Y')=2 for subject 3 > > thanks! > xiao >
|
Pages: 1 Prev: Data Step error handling Next: UNSUBSCRIBE |