calcs from two files

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

calcs from two files

Gary Stevens-2
I would like to select and open data in one file and divide it from data
in a separate file and save it in a third i.e. deaths form heart disease
divided by population equals death rate.  How can I perform computations
between two distinct files?  (my first post!)
Reply | Threaded
Open this post in threaded view
|

Re: calcs from two files

Beadle, ViAnn
Your question is way too general.
 
What does file 1 look like? What is your case unit. Is it a person, hospital, etc.
What does file 2 look like? How would you match a case from file 2 to a case from file 1.

________________________________

From: SPSSX(r) Discussion on behalf of Gary E Stevens
Sent: Fri 9/22/2006 7:24 AM
To: [hidden email]
Subject: calcs from two files



I would like to select and open data in one file and divide it from data
in a separate file and save it in a third i.e. deaths form heart disease
divided by population equals death rate.  How can I perform computations
between two distinct files?  (my first post!)
Reply | Threaded
Open this post in threaded view
|

Re: calcs from two files

Art Kendall
In reply to this post by Gary Stevens-2
You need to bring them into the same file.
If I am reading between the lines correctly, you have a file of cases
where each case has (a) variable(s) that define which population it is in.
There are many cases in each population.

You also have a file with (a)variables(s) that define populations. It
has one line (case) for each population.

You would SORT  file by the population defining variables and do a MATCH
FILES

something like this untested syntax should work.

get file 'd:\project\big_file.sav'.
dataset name big.
sort cases by county sex race.
get file 'd:\project\pop_totals.sav'.
dataset name pop.
sort cases by county sex race.
match files
  /file=big
  /table=pop
  /by county sex race.
compute newvar1= casevar1/popvar1.
compute newvar2= casevar2/popvar2.
save outfile = d:\project\new_output.sav'.

If this is not what you are looking for please explain your task in more
detail, perhaps with small examples set of data and the wanted result.

Art Kendall
Social Research Consultants






Gary E Stevens wrote:

>I would like to select and open data in one file and divide it from data
>in a separate file and save it in a third i.e. deaths form heart disease
>divided by population equals death rate.  How can I perform computations
>between two distinct files?  (my first post!)
>
>
>
>
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: calcs from two files

Gary Stevens-2
In reply to this post by Gary Stevens-2
File 1 is a Deaths-2004 file from New York State Dept of Health, I recoded
or computed each case (about 85,000) into variables I use - Cause of
death, Gender, Race-Ethnicity, Age groupings, County.  These variables
will be counted.  File 2 are population numbers for NY I organized the
same way (totaling about 50 cases).  In simple terms I want to
select “Heart disease, Females, Hispanic, 45-64 yrs old, Monroe County and
divide that number by the population of Females, Hispanic,45-64, Monroe
county. I aggregated the populations.  There is not a direct matching
variable between the two files.  Do I need to create that variable? I
ultimately want to create death rates for 20 causes of death for 4 race-
ethnicities, male female and total, 7 agegrps and 12 counties.
Reply | Threaded
Open this post in threaded view
|

Re: calcs from two files

Scott Czepiel
On 9/22/06, Gary E Stevens <[hidden email]> wrote:
>
> county. I aggregated the populations.  There is not a direct matching
> variable between the two files.  Do I need to create that variable? I
>

You do not need one single match variable.  It appears you have type,
gender, race, age, and county (5 variables) as unique identifiers.  You will
want to match the files in a one to many fashion such that the population
count in file 2 is appended to each of the 85000 observations in file 1.
Then you can divide the aggregated count in file 1 by the total population
for that group and voila you will have your answer.

Try something along these lines:

* Sort both files first so the match will work.
sort cases by type gender race age county.

* link the files.
match files file='file1.sav' /table='file2.sav'
  /by type gender race age county.
Reply | Threaded
Open this post in threaded view
|

Re: calcs from two files

Gary Stevens-2
In reply to this post by Gary Stevens-2
I am brand new to the list and 6 months new to SPSS.  I want to thank Art
Kendall, Scott Czepiel and ViAnn Beadle for giving me a nudge (OK, push)in
the right direction.  From what I've been reading in the posts this is
usually all that is needed.  Many thanks for this wonderful resource.