|
Hello All,
I am attempting to translate a SAS program to SPSS syntax. The structure of the SPSS program currently is NEW file. INPUT PROGRAM. Loop ii=1 to 5. computation code goes here end loop. end case. END FILE. END INPUT PROGRAM. execute. list variables=.... /cases=1/format=numbered. execute. I want to be able to output results (to the SPSS data editor and the output window) at the end of iteration of the loop so that five cases are created rather than one and I want to create and output a string variable during each iteration. In SAS I would do this in a data step and would write string var name ='expression'; to create the string variable and put the keyword output; at the end of each iteration in order to output the results of the iteration. If anyone can provide an explanation of how to do what i am attempting to do I will appreciate it. Jamie -- James Algina Professor Educational Psychology 1423D Norman Hall P.O. Box 117047 University of Florida Gainesville, FL 32611 Voice 352-392-0724 x 247 Fax 352-392-5929 |
|
I have figured out how to create the string variable, but would
appreciate any help explaining how to create five cases. On Fri May 04 18:27:30 EDT 2007, James Algina <[hidden email]> wrote: > Hello All, > > I am attempting to translate a SAS program to SPSS syntax. The > structure of the SPSS program currently is > > NEW file. > INPUT PROGRAM. > Loop ii=1 to 5. > > computation code goes here > > end loop. > end case. > END FILE. > END INPUT PROGRAM. > execute. > list variables=.... /cases=1/format=numbered. > execute. > > I want to be able to output results (to the SPSS data editor and > the output window) at the end of iteration of the loop so that > five cases are created rather than one and I want to create and > output a string variable during each iteration. > > In SAS I would do this in a data step and would write > > string var name ='expression'; to create the string variable > and put the keyword output; at the end of each iteration in order > to output the results of the iteration. > > > If anyone can provide an explanation of how to do what i am > attempting to do I will appreciate it. > > Jamie > -- > James Algina > Professor > Educational Psychology > 1423D Norman Hall > P.O. Box 117047 > University of Florida > Gainesville, FL 32611 > > Voice 352-392-0724 x 247 > Fax 352-392-5929 > > > -- James Algina Professor Educational Psychology 1423D Norman Hall P.O. Box 117047 University of Florida Gainesville, FL 32611 Voice 352-392-0724 x 247 Fax 352-392-5929 |
|
At 06:47 PM 5/4/2007, James Algina wrote:
>I would appreciate any help explaining how to create five cases. > >On Fri May 04 18:27:30 EDT 2007, James Algina <[hidden email]> wrote: By the way, I don't seem to have received your first posting. >>The structure of the SPSS program currently is >> >>NEW file. >>INPUT PROGRAM. >>Loop ii=1 to 5. >> >>computation code goes here >> >>end loop. >>end case. >>END FILE. >>END INPUT PROGRAM. >>execute. >>list variables=.... /cases=1/format=numbered. >>execute. >> >>I want to output results (to the SPSS data editor and the output >>window) at the end of iteration of the loop so that five cases are >>created rather than one and I want to create and output a string >>variable during each iteration. I think you just want to move the "end case." statement inside your loop. "end case" is a pretty close equivalent to SAS's "output". You don't, by the way, need either "execute" statement. (Sorry. Eliminating "execute"s is one of my favorite hobby horses.) Good luck, Richard >>In SAS I would do this in a data step and would write >> >>string var name ='expression'; to create the string variable >>and put the keyword output; at the end of each iteration in order >>to output the results of the iteration. >> >> >>If anyone can provide an explanation of how to do what i am >>attempting to do I will appreciate it. >> >>Jamie >>-- >>James Algina >>Professor >>Educational Psychology >>1423D Norman Hall >>P.O. Box 117047 >>University of Florida >>Gainesville, FL 32611 >> >>Voice 352-392-0724 x 247 >>Fax 352-392-5929 >> >> > > > >-- >James Algina >Professor >Educational Psychology >1423D Norman Hall >P.O. Box 117047 >University of Florida >Gainesville, FL 32611 > >Voice 352-392-0724 x 247 >Fax 352-392-5929 > > > >-- >No virus found in this incoming message. >Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: >269.6.2/787 - Release Date: 5/3/2007 2:11 PM |
|
Maybe a correction about "execute".
At 10:05 PM 5/4/2007, Richard Ristow wrote: >At 06:47 PM 5/4/2007, James Algina wrote: > >>The structure of the SPSS program currently is >> >>NEW file. >>INPUT PROGRAM. >>[...] >>END FILE. >>END INPUT PROGRAM. >>execute. >>list variables=.... /cases=1/format=numbered. >>execute. > >You don't, by the way, need either "execute" statement. You don't need them, to have the program work. But it may not show up in the Data Editor immediately, if you don't have an EXECUTE. SPSS does 'lazy' data creation and transforming, carrying it out only when a pass through the data is requested by a procedure. "execute" is a null procedure. The 'list' may force the pass, but if you are listing only on case, SPSS may stop after that one. However, you definitely don't need more than one of the "execute"s. |
|
AFAIK, LIST will result in a data pass of the entire file, regardless of the CASES specification; so I think both EXECUTE statements are unnecessary.
Consider the following: data list free /x y. begin data 1 2 3 4 5 6 end data. compute newvar=x+y. list /cases=1. In the Data Editor, you should see calculated values of newvar for all cases, which should mean that all cases have been read. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Richard Ristow Sent: Friday, May 04, 2007 9:31 PM To: [hidden email] Subject: Re: Output Maybe a correction about "execute". At 10:05 PM 5/4/2007, Richard Ristow wrote: >At 06:47 PM 5/4/2007, James Algina wrote: > >>The structure of the SPSS program currently is >> >>NEW file. >>INPUT PROGRAM. >>[...] >>END FILE. >>END INPUT PROGRAM. >>execute. >>list variables=.... /cases=1/format=numbered. >>execute. > >You don't, by the way, need either "execute" statement. You don't need them, to have the program work. But it may not show up in the Data Editor immediately, if you don't have an EXECUTE. SPSS does 'lazy' data creation and transforming, carrying it out only when a pass through the data is requested by a procedure. "execute" is a null procedure. The 'list' may force the pass, but if you are listing only on case, SPSS may stop after that one. However, you definitely don't need more than one of the "execute"s. |
|
In reply to this post by James Algina
Move the END CASE command inside the loop.
Jonathan Fry SPSS Inc. ________________________________ From: SPSSX(r) Discussion on behalf of James Algina Sent: Fri 5/4/2007 5:47 PM To: [hidden email] Subject: Re: Output I have figured out how to create the string variable, but would appreciate any help explaining how to create five cases. On Fri May 04 18:27:30 EDT 2007, James Algina <[hidden email]> wrote: > Hello All, > > I am attempting to translate a SAS program to SPSS syntax. The > structure of the SPSS program currently is > > NEW file. > INPUT PROGRAM. > Loop ii=1 to 5. > > computation code goes here > > end loop. > end case. > END FILE. > END INPUT PROGRAM. > execute. > list variables=.... /cases=1/format=numbered. > execute. > > I want to be able to output results (to the SPSS data editor and > the output window) at the end of iteration of the loop so that > five cases are created rather than one and I want to create and > output a string variable during each iteration. > > In SAS I would do this in a data step and would write > > string var name ='expression'; to create the string variable > and put the keyword output; at the end of each iteration in order > to output the results of the iteration. > > > If anyone can provide an explanation of how to do what i am > attempting to do I will appreciate it. > > Jamie > -- > James Algina > Professor > Educational Psychology > 1423D Norman Hall > P.O. Box 117047 > University of Florida > Gainesville, FL 32611 > > Voice 352-392-0724 x 247 > Fax 352-392-5929 > > > -- James Algina Professor Educational Psychology 1423D Norman Hall P.O. Box 117047 University of Florida Gainesville, FL 32611 Voice 352-392-0724 x 247 Fax 352-392-5929 |
| Free forum by Nabble | Edit this page |
