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 (November 2006)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 22 Nov 2006 10:55:48 -0600
Reply-To:     "Oliver, Richard" <roliver@spss.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         "Oliver, Richard" <roliver@spss.com>
Subject:      Re: Concatenate values of string variables
Comments: To: Juergen Pueschel <juergen.pueschel@OMDG.DE>
In-Reply-To:  A<200611221645.kAMGSZX0025125@mailgw.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Complete solution without the Replace function:

string newvar (a30). do repeat x=v1 to v5. if x <> ' ' newvar=concat(rtrim(newvar), ' & ', rtrim(x)). end repeat. compute newvar=substr(newvar,4).

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Juergen Pueschel Sent: Wednesday, November 22, 2006 10:45 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: Concatenate values of string variables

Dear Melissa, thanks for the (good) idea. But the replace-command doesn't work, because my SPSS-Version is 12.0. Do you have any other suggestions to include the ampersands?

Best regards

Juergen

On Wed, 22 Nov 2006 10:19:23 -0600, Melissa Ives <mives@chestnut.org> wrote:

>If you REALLY want the ampersands (&) between each variable, this >works... > >string newvar (A25). >compute newvar=concat(v1," & ",V2," & ",V3," & ",V4," & ",V5). >compute newvar=replace(newvar," &",""). >if (substr(newvar,length(rtrim(newvar))-1,2)=" &") >newvar=(substr(newvar2,1,length(rtrim(newvar2)))). >if (substr(newvar,1,5)=" & ") newvar=substr(newvar,6). >exe. > >Let me know if you have any questions. > >Melissa > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf >Of Juergen Pueschel >Sent: Wednesday, November 22, 2006 8:51 AM >To: SPSSX-L@LISTSERV.UGA.EDU >Subject: [SPSSX-L] Concatenate values of string variables > >Dear listmembers, > >I would like to concatenate the values of 5 string-variables in one new >variable. Variables with no values should not be concatenated with the >other variables. > >For example: > >V1 V2 V3 V4 V5 Newvar > >aa bb cc dd ee aa & bb & cc & dd & ee >aa cc ee aa & cc & ee >aa ee aa & ee > ee ee > > >Juergen > > > >PRIVILEGED AND CONFIDENTIAL INFORMATION This transmittal and any >attachments may contain PRIVILEGED AND CONFIDENTIAL information and is >intended only for the use of the addressee. If you are not the >designated recipient, or an employee or agent authorized to deliver >such transmittals to the designated recipient, you are hereby notified >that any dissemination, copying or publication of this transmittal is >strictly prohibited. If you have received this transmittal in error, >please notify us immediately by replying to the sender and delete this >copy from your system. You may also call us at (309) 827-6026 for >assistance.


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