Quantcast

Merging NHIS data

classic Classic list List threaded Threaded
4 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Merging NHIS data

mstavr3
Dear colleagues,

We are trying to insert the "interview quarter" variable into the persons data set for 2004. We tried pulling that variable from the household data file and have not been successful. I am wondering if anybody has recommendations?

Thanks,
Marina
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Merging NHIS data

Bruce Weaver
Administrator
Hi Marina.  I don't know anything about the NHIS data, but it sounds like you want to extract quarter from a date variable.  If the persons data set has a date variable, try the following, replacing my DateVar with the name of the date variable you have:

* Compute two numeric variables, Quarter & Year.
COMPUTE Quarter = XDATE.QUARTER(DateVar).
COMPUTE Year = XDATE.YEAR(DateVar).
* Alternatively, compute a Date-variable that displays quarter & year.
COMPUTE QuarterVar = DateVar.
FORMATS Quarter(F1) / Year(F4.0) / QuarterVar(QYR8).
EXECUTE.

Here's an example using a small dataset I made up.

NEW FILE.
DATASET CLOSE all.
DATA LIST list / DateVar(DATE11).
BEGIN DATA
24-Feb-2016
24-May-2016
24-Jul-2016
24-Oct-2016
END DATA.
COMPUTE Quarter = XDATE.QUARTER(DateVar).
COMPUTE Year = XDATE.YEAR(DateVar).
COMPUTE QuarterVar = DateVar.
FORMATS Quarter(F1) / Year(F4.0) / QuarterVar(QYR8).
LIST.

OUTPUT:

    DateVar Quarter Year QuarterVar
 
24-FEB-2016    1    2016  1 Q 2016
24-MAY-2016    2    2016  2 Q 2016
24-JUL-2016    3    2016  3 Q 2016
24-OCT-2016    4    2016  4 Q 2016
 
Number of cases read:  4    Number of cases listed:  4

If this is not doing what you want, please clarify.  A small example of what the data looks like now followed by what you want it to look like afterwards is always very helpful.  


mstavr3 wrote
Dear colleagues,

We are trying to insert the "interview quarter" variable into the persons data set for 2004. We tried pulling that variable from the household data file and have not been successful. I am wondering if anybody has recommendations?

Thanks,
Marina
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Merging NHIS data

Mike
In reply to this post by mstavr3
On Monday, October 24, 2016 12:48 PM, mstavr3 wrote:
> Dear colleagues,
>
> We are trying to insert the "interview quarter" variable into the
> persons
> data set for 2004. We tried pulling that variable from the household
> data
> file and have not been successful. I am wondering if anybody has
> recommendations?

I don't really work with NHIS data but looking at the documentation
let me see if I'm interpreting it correctly:

(1)  In the HOUSEHOLD data file the variable that identifies the
quarter is listed below (along with freq info):

INTV_QRT: Interviewing Quarter
INTV_QRT Frequency Percent
------------------------------------
1 Quarter 1 9761 23.19
2 Quarter 2 8915 21.18
3 Quarter 3 11711 27.82
4 Quarter 4 11702 27.80

So, is this what you're referring to as the variable from the household
dataset?

(2)  In the HOUSEHOLD data file the variable that identifies the
household is listed below:

HHX Household Serial Number
HHX Frequency Percent
-----------------------------------
All Values 42089 100.00

Is this correct?

(3) In the PERSON data file the corresponding variable is

HHX: Household Serial Number
HHX Frequency Percent
----------------------------------
All Values 94460 100.00

Is this correct?

(4)  If I have the above correct, it seems to me that you want to
save the quarter variable and the household serial number to
a seperate file (only two variables). Assume you save to:

"c:\NHIS-Data-001\NHIS2004-Hous-2vars.sav"

(5) You then want to run a Match Files command that looks something
like the following (assuming PERSON data file is open in SPSS)

Match files
  table="c:\NHIS-Data-001\NHIS2004-Hous-2vars.sav"  /* name of SPSS sav
file with 2 vars
  /file = *                                                /* use
currently open Person file
  /by INTV_QRT.                          /* Household serial number

freq var=INTV_QRT.

Note that the houshold file has only 42,089 cases while the
person file has 94,460 cases. The frequency procedure
in (5) should produce a table with 94,460 values for INTV_QRT.

Is the above what you tried?  It's been a while since I use the match
files, so if anyone sees any problems, give a shoutout.

-Mike Palij
New York University
[hidden email]

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fw: Merging NHIS data

Mike
In reply to this post by mstavr3
----- Original Message -----
> Match files
>  table="c:\NHIS-Data-001\NHIS2004-Hous-2vars.sav"  /* name of SPSS sav
>  > file with 2 vars
>  /file = *                                                /* use >
> currently open Person file
>  /by INTV_QRT.                          /* Household serial number
>
> freq var=INTV_QRT.

Oy! the /by INTV_QRT above should be /by HHX.

-Mike Palij
New York University
[hidden email]

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Loading...