LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 7 Jan 2008 23:52:11 -0500
Reply-To:     Richard Ristow <wrristow@mindspring.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Richard Ristow <wrristow@mindspring.com>
Subject:      Re: Merging 2 numeric variables to match another date variable
Comments: To: Manny Estrada <estradam@fiu.edu>
In-Reply-To:  <000a01c8517c$455ee2a0$d01ca7e0$@edu>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 05:25 PM 1/7/2008, Manny Estrada wrote:

>I have 2 datasets that I need to merge. But, I have a little issue. > >In dataset #1, I have a DATE variable (APR 2000) in one field. >In dataset#2, I have 2 separate NUMERIC variables (4),(2000) in two fields. > >What I need is to merge these numeric variables, and match the date variable.

"APR 2000" has to be a string variable. Assuming that's how you want your month-year dates, something like this should work, though not tested. It assumes that, . The first dataset can be read as 'Dataset1', and the second as 'Dataset2' . The string variable in the first dataset is 'Date'; the numeric variables in the second dataset are 'Month' and 'Year'.

GET FILE=Dataset2. STRING Date (A8).

* Convert the numeric month into its three-letter . * abbreviation. This is a roundabout calculation, . * through an SPSS date value that is the first day . * of that month in the year 2000. .

NUMERIC #Month (DATE11). COMPUTE #Month= DATE.MDY(Month,1,2000). COMPUTE Date = STRING(#Month,MONTH3).

* Add the four-digit year to the field .

COMPUTE Date = CONCAT(RTRIM(Date), ' ' , STRING(Year,F4)).

* Now merge (I assume you mean adding cases), with . * only the string form of the date being kept. .

* (Add /BY, /RENAME, etc., as you need to.) .

ADD FILES /FILE=Dataset1 /FILE=* /DROP=Month Year.

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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


Back to: Top of message | Previous page | Main SPSSX-L page