Hello Dear All,
I wonder if you know how I can get the 2 or 3 first character of a value.for example I have XX variable with following value: 1|01/02/2005 1|02/03/2005 14|04/08/2006 .. .. I want to create a new variable from this variable which contains just frist 2 or 3 character of this values: 1 1 14 Do you have any idea? Thanks in advance Behnaz Shirazi .. _________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ |
In this case, it would appear that you want everything prior to "|", so:
*create some sample data. data list list (",") /oldstring (a15). begin data 1|01/02/2005 1|02/03/2005 14|04/08/2006 end data. *now the code to create the new variable. string newstring (a3). compute newstring=substr(oldstring, 1, index(oldstring, "|")-1). execute. /*to see the result immediately. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of behnaz shirazi Sent: Friday, March 02, 2007 12:03 PM To: [hidden email] Subject: [BULK] frist ? character of value Importance: Low Hello Dear All, I wonder if you know how I can get the 2 or 3 first character of a value.for example I have XX variable with following value: 1|01/02/2005 1|02/03/2005 14|04/08/2006 .. .. I want to create a new variable from this variable which contains just frist 2 or 3 character of this values: 1 1 14 Do you have any idea? Thanks in advance Behnaz Shirazi .. _________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ |
Thank you so much Oliver,
It works fine for me .Just I have a original problem which I don't know how to fix.My main problem is that I have several dates ,let's say , T1, T2, T3....... to T24.I want to find the max T (date) .Up to now it is ok because I get the max of all dates but each date has number and other characteristics which I need to have them as well.But I don't know how I can get this variables after findinf max T. In fact I don't know after findind MAX how I can search it through my file to catch the number of this T and other information. Do you have any idea in this case? I appreciated your help Thanks again Behnaz >From: "Oliver, Richard" <[hidden email]> >Reply-To: "Oliver, Richard" <[hidden email]> >To: [hidden email] >Subject: Re: [BULK] frist ? character of value >Date: Fri, 2 Mar 2007 12:30:38 -0600 > >In this case, it would appear that you want everything prior to "|", so: > >*create some sample data. >data list list (",") /oldstring (a15). >begin data >1|01/02/2005 >1|02/03/2005 >14|04/08/2006 >end data. >*now the code to create the new variable. >string newstring (a3). >compute newstring=substr(oldstring, 1, index(oldstring, "|")-1). >execute. /*to see the result immediately. > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of >behnaz shirazi >Sent: Friday, March 02, 2007 12:03 PM >To: [hidden email] >Subject: [BULK] frist ? character of value >Importance: Low > >Hello Dear All, > >I wonder if you know how I can get the 2 or 3 first character of a >value.for >example I have XX variable with following value: > >1|01/02/2005 >1|02/03/2005 >14|04/08/2006 >.. >.. >I want to create a new variable from this variable which contains just >frist >2 or 3 character of this values: >1 >1 >14 > > >Do you have any idea? > >Thanks in advance >Behnaz Shirazi > > > > > >.. > >_________________________________________________________________ >FREE pop-up blocking with the new MSN Toolbar - get it now! >http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ _________________________________________________________________ Don't just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/ |
Free forum by Nabble | Edit this page |