Counting Values Over Many Variables

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Counting Values Over Many Variables

Krinsky, Alan-2
Counting Values Over Many Variables

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?"
"I always thought that record would stand until it was broken."
-Yogi Berra

Alan D. Krinsky  PhD, MPH
Medical Management Interventions Manager
UMass Memorial Health Care
Hahnemann Campus
281 Lincoln St.
Worcester, MA 01605
Phone: 508-334-5854
Fax: 508-793-6086
E-mail: [hidden email]

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, transmission, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
Reply | Threaded
Open this post in threaded view
|

Re: Counting Values Over Many Variables

John F Hall
Counting Values Over Many Variables
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 -----
Sent: Wednesday, January 20, 2010 11:57 PM
Subject: Counting Values Over Many Variables

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?"
"I always thought that record would stand until it was broken."
-Yogi Berra

Alan D. Krinsky  PhD, MPH
Medical Management Interventions Manager
UMass Memorial Health Care
Hahnemann Campus
281 Lincoln St.
Worcester, MA 01605
Phone: 508-334-5854
Fax: 508-793-6086
E-mail: [hidden email]

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, transmission, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
Reply | Threaded
Open this post in threaded view
|

Re: Counting Values Over Many Variables

Dennis Deck
In reply to this post by Krinsky, Alan-2
Counting Values Over Many Variables

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]]
Sent: Wednesday, January 20, 2010 2:58 PM
Subject: Counting Values Over Many Variables

 

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?"
"I always thought that record would stand until it was broken."
-Yogi Berra

Alan D. Krinsky  PhD, MPH
Medical Management Interventions Manager
UMass Memorial Health Care
Hahnemann Campus
281 Lincoln St.
Worcester, MA 01605
Phone: 508-334-5854
Fax: 508-793-6086
E-mail: [hidden email]

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, transmission, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.