|
Is it possible to count a group of values spread over a number of variables, without resorting to brute force? Let's say, for example, I have 30 variables, named Visit1 through Visit30, and for each person there is one row identifying the Month-Year of each visit. For each person, there are dates, up to 30, but not necessarily 30 for each person. And the dates are in chronological order, but if one person's first visit was April-2008 it would be under Visit1, whereas another person might have April-2008 under Visit20. I want to be able to count, for example, for each person-row how many visits occurred during 2008 (and not simply count all visits), where visits could span a number of years. This means looking in each of the 30 Visit variables for any of the 12 Month-Year possibilities for 2008, and then counting how many matches there are. I was trying to use IF, but I see I cannot use "Visit1 TO Visit30" within an IF command. I also tried creating binary variables for each Month-Year and then restructuring the data by patient, but this created hundreds of new variables. I am thinking this requires some sort of LOOP approach, but I am not certain. Thanks, and be well! Alan Krinsky "If people don't want to come out to the ballpark, how are you going to stop them?"
|
|
Without seeing your data it looks as if you could
try using something like:
count <year>visit = visit1 to visit30 (
<value list> ) .
eg where <year>visit is
visit2008 and
<value
list> is Jan_2008 thru Dec_2008 and
then
count visit2008 = visit1 to
visit30 (Jan_2008 thru Dec_2008).
Repeat for each year and then run
frequencies.
freq
<visityears> .
eg
freq
visit2008.
----- Original Message -----
|
|
In reply to this post by Krinsky, Alan-2
One approach might be: COMPUTE Visit08 = ANY(2008, XDATE.Year(Visit1),
XDATE.Year(Visit2), . . . ) . Another might be: COMPUTE Visit08 = 0 . REPEAT v = Visit1 to Visit30. + IF (XDATE.Year( v) = 2008) Visit08
= 1 . END REPEAT . In both cases Visit08 will be 1 if found
or 0 if not found across the 30 dates for that case. I assume these were date variables. Dennis From: Krinsky, Alan
[mailto:[hidden email]] Is
it possible to count a group of values spread over a number of variables,
without resorting to brute force? Let's
say, for example, I have 30 variables, named Visit1 through Visit30, and for
each person there is one row identifying the Month-Year of each visit. For each
person, there are dates, up to 30, but not necessarily 30 for each person. And
the dates are in chronological order, but if one person's first visit was
April-2008 it would be under Visit1, whereas another person might have
April-2008 under Visit20. I
want to be able to count, for example, for each person-row how many visits
occurred during 2008 (and not simply count all visits), where visits could span
a number of years. This means looking in each of the 30 Visit variables for any
of the 12 Month-Year possibilities for 2008, and then counting how many matches
there are. I
was trying to use IF, but I see I cannot use "Visit1 TO Visit30"
within an IF command. I also tried creating binary variables for each
Month-Year and then restructuring the data by patient, but this created
hundreds of new variables. I am thinking this requires some sort of Thanks,
and be well! Alan
Krinsky "If people don't want
to come out to the ballpark, how are you going to stop them?"
|
| Free forum by Nabble | Edit this page |
