Hello,
I have been searching the list archives but I haven't found what I needed. I am trying to use WRITE OUTFILE to generate a IF-THEN syntax: WRITE OUTFILE=!TEMP+"TEMP.SPS" /'IF UPCASE(Q687_D'Id_Domanda_1') 'Operatore_logico_1' "'Testo_risposta_1'" Valore=0.'. EXE. What I get is: IF UPCASE(Q687_D 1) = "NON SAPREI " Valore=0. IF UPCASE(Q687_D 902) = "ALTRO " Valore=0. IF UPCASE(Q687_D 166) = "NON SO COSA SIA " Valore=0. IF UPCASE(Q687_D 167) = "NON SO COSA SIA " Valore=0. But what I would like to get is: IF UPCASE(Q687_D1) = "NON SAPREI" Valore=0. IF UPCASE(Q687_D902) = "ALTRO" Valore=0. IF UPCASE(Q687_D166) = "NON SO COSA SIA" Valore=0. IF UPCASE(Q687_D167) = "NON SO COSA SIA" Valore=0. So I need to elimintate blank spaces in the text. Any suggestion? Thank you, Luca Mr. Luca MEYER Market research, data analysis & more www.lucameyer.com - Tel: +39.339.495.00.21 |
At 12:15 PM 2/10/2007, Luca Meyer wrote:
>I am trying to use WRITE OUTFILE to generate a IF-THEN syntax: Ah, code-generating code can be the trickiest code there is. >WRITE OUTFILE=!TEMP+"TEMP.SPS" > /'IF UPCASE(Q687_D'Id_Domanda_1') 'Operatore_logico_1' > "'Testo_risposta_1'" >Valore=0.'. >EXE. > >What I get is: > >IF UPCASE(Q687_D 1) = "NON SAPREI >" Valore=0. > >But what I would like to get is: > >IF UPCASE(Q687_D1) = "NON SAPREI" Valore=0. > >So I need to elimintate blank spaces in the text. Any suggestion? I don't think you can do what you want, by any syntax possible with WRITE. When I've written code for such purposes, I've done it like this (not tested). It assumes that Id_Domanda_1 is numeric, and all your other named variables are strings. I've split lines, and indented, to make the logic of the generated line as clear as I can. STRING #CODE (A60). COMPUTE #CODE = CONCAT( 'IF UPCASE(Q687_D' , LTRIM(STRING(Id_Domanda_1,F3)) , ') ' , Operatore_logico_1 , ' "' , RTRIM(Testo_risposta_1) , '" Valore=0.' ). WRITE OUTFILE=!TEMP+"TEMP.SPS" /#CODE. EXE. |
Thank you Richard the code works perfectly -- Luca
-----Messaggio originale----- Da: Richard Ristow [mailto:[hidden email]] Inviato: domenica 11 febbraio 2007 0.59 A: Luca Meyer; [hidden email] Oggetto: Re: Write outfile At 12:15 PM 2/10/2007, Luca Meyer wrote: >I am trying to use WRITE OUTFILE to generate a IF-THEN syntax: Ah, code-generating code can be the trickiest code there is. >WRITE OUTFILE=!TEMP+"TEMP.SPS" > /'IF UPCASE(Q687_D'Id_Domanda_1') 'Operatore_logico_1' > "'Testo_risposta_1'" >Valore=0.'. >EXE. > >What I get is: > >IF UPCASE(Q687_D 1) = "NON SAPREI >" Valore=0. > >But what I would like to get is: > >IF UPCASE(Q687_D1) = "NON SAPREI" Valore=0. > >So I need to elimintate blank spaces in the text. Any suggestion? I don't think you can do what you want, by any syntax possible with WRITE. When I've written code for such purposes, I've done it like this (not tested). It assumes that Id_Domanda_1 is numeric, and all your other named variables are strings. I've split lines, and indented, to make the logic of the generated line as clear as I can. STRING #CODE (A60). COMPUTE #CODE = CONCAT( 'IF UPCASE(Q687_D' , LTRIM(STRING(Id_Domanda_1,F3)) , ') ' , Operatore_logico_1 , ' "' , RTRIM(Testo_risposta_1) , '" Valore=0.' ). WRITE OUTFILE=!TEMP+"TEMP.SPS" /#CODE. EXE. |
Free forum by Nabble | Edit this page |