Jims
This will do it:
COMPUTE var2=NUMBER(CHAR.SUBSTR(var1,1, 4),f4).
COMPUTE var3=NUMBER(CHAR.SUBSTR(var1,6, 4),f4).
Always assuming the format is YYYY-YYYY
Best Wishes
John S. Lemon
DIT ( Directorate of Information Technology ) - Student Liaison Officer
University of Aberdeen
Edward Wright Building: Room G51
Tel: +44 1224 273350
Fax: +44 1224 273372
Diary ( Free / Busy )
From: SPSSX(r) Discussion [mailto:[hidden email]]
On Behalf Of Jims More
Sent: 12 May 2009 08:44
To: [hidden email]
Subject: Splitting string variable
I have a string variable (var1) presented below. I want to split var1 by creating two variables (var2 and var3) such that var2 contains the first four-digit numbers while var3 contains the last four-digit numbers.
I need a syntax. I've been trying to browse from the web as well as in this list but unlucky. I am hoping for your kind help on this.
|
Chat right from the comfort of your inbox.
Show me how..
The University of Aberdeen is a charity registered in Scotland, No SC013683.