|
I could use some help with a DO REPEAT LOOP program.
I have 500 rows of frequency data for multiple variables that I need to run the same statistical procedure on ( a log-linear analysis if that's relevant). I am using the id variable CASE as my counter (1 to 500). I tried the following code to test out the loop but cannot get it to run: INPUT PROGRAM. LOOP #I = 1 TO 500. Do Repeat TOTAL = Case. Compute Total=Case+1. End Repeat. END LOOP. END FILE. END INPUT PROGRAM. TOTAL is the counting variable that I want to stop at 500. I am not certain as to where I would put the statiscal command. I assume just before the 'End Repeat' statement. I must apologize but I am a complete novice in the use of LOOPS in SPSS. Any advice would be appreicated. Michael Kruger ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
At 08:20 PM 4/10/2008, Michael Kruger wrote:
>I could use some help with a DO REPEAT LOOP program. >I am using the id variable CASE as my counter (1 to 500). I tried the >following code to test out the loop but cannot get it to run: > >INPUT PROGRAM. >LOOP #I = 1 TO 500. > Do Repeat TOTAL = Case. > Compute Total=Case+1. > End Repeat. >END LOOP. >END FILE. >END INPUT PROGRAM. I'll start with this, but I don't think it's the real problem. You have a couple of problems with this program: . When you write data from an INPUT PROGRAM without reading any in, you need an END CASE statement whenever a case is complete and you want it to be output. . In your DO REPEAT, 'TOTAL' is not a variable, but a "stand-in variable" -- it stands in for every variable in its list, in turn. So, it won't be in the output file at all. . As you have it, 'Case' is never assigned any value, so it'll always be system-missing. Try the following (I've run it for for 5 cases only). It works, but I'm not confident it's what you want: INPUT PROGRAM. NUMERIC Case TOTAL (F5). LEAVE Case. LOOP #I = 1 TO 5. . COMPUTE Case = #I. . COMPUTE Total = Case+1. . END CASE. END LOOP. END FILE. END INPUT PROGRAM. LIST. List |-----------------------------|---------------------------| |Output Created |10-APR-2008 23:28:11 | |-----------------------------|---------------------------| Case TOTAL 1 2 2 3 3 4 4 5 5 6 Number of cases read: 5 Number of cases listed: 5 Now, to what may be the real problem: >I have 500 rows of frequency data for multiple variables that I need >to run the same statistical procedure on ( a log-linear analysis if >that's relevant). I am not certain as to where I would put the >statistical command. I assume just before the 'End Repeat' statement. No. A statistical procedure can't be inside either a LOOP/END LOOP or a DO REPEAT/END REPEAT. Those commands loop across variables, within each case. They're used in transformation programs and INPUT PROGRAMS, which process all cases in the file in sequence. A statistical procedure operates on all the cases in the file. Can you post more exactly what you want to do? For "multiple variables that I need to run the same statistical procedure on", you use a macro loop or a loop in Python. But if you give us your variables, and how you'd set up the procedure for one of them, we can be more exact in responding. -Best of luck, Richard ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
I am trying to create a bar-chart in SPSS where the width of each bar varies according to a second variable (representing, say, importance or sample size).
SPSS support told me I need to use GPL, something I have no experience of. Can anyone help please? Thanks in advance, Karsten Consider the environment before printing this email ***************************************************** Any views or opinions are solely those of the author and do not necessarily represent those of GfK NOP or any of its associated companies. ***************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient of this message, please do not read, copy, use or disclose this communication and notify the sender immediately. It should be noted that any review, retransmission, dissemination or other use of, or taking action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. ***************************************************** Recipients are warned that GfK NOP cannot guarantee that attachments or enclosures are secure or error-free as information could be intercepted, corrupted, or contain viruses ***************************************************** GfK NOP Limited,Ludgate House,245 Blackfriars Road,London SE1 9UL Place of registration:England and Wales Company number:2512551 Registered office:GfK NOP Limited,14 New Street,London,EC2M 4HE ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Here's an example using the Employee data.sav example data file. Bars are
sized by sample size. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=jobcat salary MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: jobcat=col(source(s), name("jobcat"), unit.category()) DATA: salary=col(source(s), name("salary")) GUIDE: axis(dim(1), label("Employment Category")) GUIDE: axis(dim(2), label("Mean Current Salary")) SCALE: linear(dim(2), include(0)) ELEMENT: interval(position(summary.mean(jobcat*salary)), size(summary.count(jobcat))) END GPL. For more information go to Help>Base System>GPL Reference -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Shaw, Karsten (GfK NOP, UK) Sent: Friday, April 11, 2008 7:38 AM To: [hidden email] Subject: Altering the width of bars in bar charts I am trying to create a bar-chart in SPSS where the width of each bar varies according to a second variable (representing, say, importance or sample size). SPSS support told me I need to use GPL, something I have no experience of. Can anyone help please? Thanks in advance, Karsten Consider the environment before printing this email ***************************************************** Any views or opinions are solely those of the author and do not necessarily represent those of GfK NOP or any of its associated companies. ***************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient of this message, please do not read, copy, use or disclose this communication and notify the sender immediately. It should be noted that any review, retransmission, dissemination or other use of, or taking action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. ***************************************************** Recipients are warned that GfK NOP cannot guarantee that attachments or enclosures are secure or error-free as information could be intercepted, corrupted, or contain viruses ***************************************************** GfK NOP Limited,Ludgate House,245 Blackfriars Road,London SE1 9UL Place of registration:England and Wales Company number:2512551 Registered office:GfK NOP Limited,14 New Street,London,EC2M 4HE ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
