Date: Wed, 23 Jun 1999 15:11:30 +0200
Reply-To: "m.feldkircher@ogilvyone.de" <m.feldkircher@ogilvyone.de>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Martin Feldkircher <m.feldkircher@OGILVYONE.DE>
Organization: OgilvyOne
Subject: AW: Selecting first 2 digits from a string variable
Content-Type: text/plain; charset="iso-8859-1"
> -----Ursprüngliche Nachricht-----
> Von: James C. Creech [SMTP:jcreech@VCSC.STATE.VA.US]
> Gesendet am: Mittwoch, 23. Juni 1999 01:13
> An: SPSSX-L@LISTSERV.UGA.EDU
> Betreff: Re: Selecting first 2 digits from a string variable
>
> string newvar (a2).
> compute newvar=oldvar.
> recode newvar (convert) into newvar2.
>
> The first two lines create a 2 byte varaiable and copies the
> first two bytes of the old variable. The third line converts
> the new string variable into the desired numeric.
>
IMHO, an easier way is the following command.
compute newvar = NUMBER(SUBSTR(oldvar,1,2),F2.0).
mf
|