# st:easy way to deal with "paired" variables?

 From Mandy fu To statalist@hsphsun2.harvard.edu Subject st:easy way to deal with "paired" variables? Date Sun, 1 Feb 2009 00:52:44 -0500

```Deal Statalisters,

I was wondering if there's any easy way to deal with the "paired" variables.

The data set I'm working on includes 100 variables measuring the time
spell of gaps between jobs. And for each gap there's a variable
explaining why the person does not work during that gap. It looks like
this: .
---------------------------------------------------------------------------------------------------------------
ID    gap1       reason1        gap2        reason2              gap 3
reason3
1    30days   1 illness         20days     2 Don't want      61 days
can't find job
2    25days   2 Don't want   180 days  4 in prison          missing    missing
3
---------------------------------------------------------------------------------------------------------------
I want to calculate the total length of  any gaps caused by being in
prison(reason=4) .

The current way I use has three steps:
---------------------------------------------------
step 1: create dummy variable =1 if the gap's reason is 4;=0 if reason is not 4
step 2: create new gaps variables ("newgap1-100" )measuring the days
for each
gap if reason =4. for example: "newgap1"="gap1" * dummy variable from
step 1.
step 3:get the row total of all the new gap variables.
egen total_prison=rowtotal(newgap1-100)
----------------------------------------------------
The total_prison is what I 'm looking for to measure the total days of
all the gaps if  the reason is 4.

I'm thinking there must be some easier way to do this.  Could anyone
here could give some idea of how to deal with these kinds of "paired"
variables?(It seems that each gap variable is paired with each reason
variable.)

Thanks a lot!

Mandy
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```