From: Albertorio, Juan R. (CDC/OPHSS/NCHS)
Dear all, I agree to help a friend to develop a spss workshop session for a graduate course. One of the exercise demands the use of the loop function and I don’t know how to do it
L Therefore, I wonder if someone from this vast universe can give me an advice here. I have the syntax in stata and SAS, but I am unable to replicate it yet using spss.
Any advice, help or criticism is welcome. Thanks!! Juan _______________________________________ Juan R. Albertorio-Díaz, MA |
To be snarky, may we be so daring to presume that after reading the spss documentation for Loop-End Loop, you are unable to do the translation? Let’s say that is so.
So, please post the sas/stata syntax and also a narrative of what the sas/stata code segment is supposed to do. My understanding is that the sas loop command has more flexibility than does the spss loop command.
In particular, sas procs may be enclosed in a loop. That is not possible in spss. In spss doing so requires defining a loop in a macro.
Gene Maguin From: SPSSX(r) Discussion [mailto:[hidden email]]
On Behalf Of Albertorio, Juan R. (CDC/OPHSS/NCHS) From: Albertorio, Juan R. (CDC/OPHSS/NCHS)
Dear all, I agree to help a friend to develop a spss workshop session for a graduate course. One of the exercise demands the use of the loop function and I don’t know how to do it
L Therefore, I wonder if someone from this vast universe can give me an advice here. I have the syntax in stata and SAS, but I am unable to replicate it yet using spss.
Any advice, help or criticism is welcome. Thanks!! Juan _______________________________________ Juan R. Albertorio-Díaz, MA ===================== 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
|
Administrator
|
In reply to this post by Albertorio, Juan R. (CDC/CCHIS/NCHS)
You should post a specific question!
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Albertorio, Juan R. (CDC/CCHIS/NCHS)
You are a little vague on what exactly you
would want to do or show
so I'm going to suggest that you check out the
UCLA Institute for
Digital Research and Education (IDRE) which
provide tutorials for
SPSS, SAS, Stata, etc. Here is their
homepage:
For a specific example using LOOP, look at the
following page,
at the bottom of the page which gives and
example of how to
use loop to compute a value across a case
(i.e., within-subject)
and how to use loop to compute a value across
cases (i.e.,
between-subjects); see:
I think that you may want to examine other
areas of the website
as well as the DO REPEAT, for an example
see:
-Mike Palij
New York University
===================== 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 |
In addition to Mike's good suggestions,
note that procedures cannot be placed inside loops, which are for casewise
transformations. However, SPLIT FILES can sometimes take the place
of a procedure loop. Also, Python programmability can easily
be used to loop procedures - either directly by coding a loop in the program
or by using one of the extension commands that can loop such as SPSSINC
PROCESS FILES.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Mike Palij <[hidden email]> To: [hidden email] Date: 12/02/2014 11:59 AM Subject: Re: [SPSSX-L] Assistance with SPSS loop-Juan Sent by: "SPSSX(r) Discussion" <[hidden email]> You are a little vague on what exactly you would want to do or show so I'm going to suggest that you check out the UCLA Institute for Digital Research and Education (IDRE) which provide tutorials for SPSS, SAS, Stata, etc. Here is their homepage: http://www.ats.ucla.edu/stat/ For a specific example using LOOP, look at the following page, at the bottom of the page which gives and example of how to use loop to compute a value across a case (i.e., within-subject) and how to use loop to compute a value across cases (i.e., between-subjects); see: http://www.ats.ucla.edu/stat/spss/faq/ccsv_compare.html I think that you may want to examine other areas of the website as well as the DO REPEAT, for an example see: http://www.ats.ucla.edu/stat/spss/code/repeat_count.htm -Mike Palij New York University mp26@... ----- Original Message ----- From: Albertorio, Juan R. (CDC/OPHSS/NCHS) To: [hidden email] Sent: Tuesday, December 02, 2014 1:26 PM Subject: FW: Assistance with SPSS loop-Juan From: Albertorio, Juan R. (CDC/OPHSS/NCHS) Sent: Tuesday, December 02, 2014 1:25 PM To: [hidden email] Subject: Assistance with SPSS loop-Juan Dear all, I agree to help a friend to develop a spss workshop session for a graduate course. One of the exercise demands the use of the loop function and I don’t know how to do it L Therefore, I wonder if someone from this vast universe can give me an advice here. I have the syntax in stata and SAS, but I am unable to replicate it yet using spss. Any advice, help or criticism is welcome. Thanks!! Juan _______________________________________ Juan R. Albertorio-Díaz, MA Statistician International Statistics Program Office of the Center Director National Center for Health Statistics Center for Disease Control and Prevention 3311 Toledo Rd. Suite 2427 Hyattsville, MD 20782 301.458.4634 301.458.4043 (Fax) JAlbertorio@... ===================== To manage your subscription to SPSSX-L,
send a message to LISTSERV@...
(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
|
Dear all,
Sorry to be so vague. Here is more details.
Just add 1 if the procedure mentioned once in any of the nine procedure register; two if present in two of the nine procedures register and so on. I think that this sort of procedure can be done using “count” in spss.
The part that I have the problem is highlighted in
RED- see below. Here is the rationale of the code. 1-Looking at the array code… 2-We first create the variable “Totproc” and set its value to 0 3-The name of the array is “procs” and it looks in any of the 9 write-in procedure variables for a code between 42XX-5499
4-If any code is present (not including -9 b/c that represents blanks) a value of 1 is added to the created variable “totproc” 5-After the program looks at every procedure variable in every visit record; it produces a frequency of “totproc” which represents the total
# of write-in procedures across all visits /*============================================================================= =============================================================================*/ /*Exercise 6 - Create new variables & estimate total number of digestive
write-in procedures*/ data namex6; set namcsduc; *************************; totproc=0; *************************; array procs(9) proc1-proc9; do j=1 to 9; nineproc = procs(j); if nineproc ge '42 ' and nineproc le '5499' then totproc=totproc+1; /*ICD-9-CM 42.00-54.99 for digestive operations/procedures. Totproc counts procedures*/ end; run; proc surveymeans data=namex6 nobs sum; cluster cpsum; strata cstratm; var totproc; weight patwt1k; Title 'Exercise 6 - 2010 NAMCS Number of write-in Digestive Procedures';
run; /*============================================================================= =============================================================================*/ From: SPSSX(r) Discussion [mailto:[hidden email]]
On Behalf Of Jon K Peck In addition to Mike's good suggestions, note that procedures cannot be placed inside loops, which are for casewise transformations. However, SPLIT FILES can sometimes take
the place of a procedure loop. Also, Python programmability can easily be used to loop procedures - either directly by coding a loop in the program or by using one of the extension commands that can loop such as SPSSINC PROCESS FILES.
===================== 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
|
Administrator
|
Here are 3 different approaches ;-)
DATA LIST FREE / PROC01 TO PROC03 (3A4). BEGIN DATA 1234 1235 7364 2342 1234 1233 2342 1234 4334 END DATA. DO REPEAT x=PROC01 TO PROC03. + COMPUTE totproc1=SUM(totproc1,RANGE(x,'42 ','5499')). END REPEAT. VECTOR proc=PROC01 TO PROC03. LOOP #=1 TO 3. + COMPUTE totproc2=SUM(totproc2,RANGE(proc(#),'42 ','5499')). END LOOP. /* Doesn't work due to variables being string ;-( */. COUNT totproc=PROC01 TO PROC03 ('42 ' THRU '5499'). /* OTOH */. RECODE PROC01 TO PROC03 (CONVERT) INTO #p1 TO #p3. COUNT totproc3=#P1 TO #P3 (4200 THRU 5499). LIST. ----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |