Looping is SPSS

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Looping is SPSS

Cristian
Hi everyone,

I need to write a loop in SPSS syntax. I know how to write it in SAS. Can
someone tell me how to write the following in SPSS syntax. Writing nested
loops with a BY statement is what is confusing me.

SAS/IML Syntax
                START Delta_Epsilon;
                        cnt =0;
                        by1 =.02;
                        by2 =.02;
                        end1=2;
                        end2=2;
                        do delta=by1 to end1 by by1 ; /* impacts kurtosis */
                                do epsilon=-end2 to end2 by by2; /* impacts skewness */
                                        cnt=cnt+1;
                                        T=sinh(delta*arsinh(Raw)-epsilon);
                                end;
                        end;
                FINISH Delta_Epsilon;


Much thanks,

Cristian



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

David Marso
Administrator
SPSS has a LOOP statement.
It takes integer arguments so you will have to fiddle with division.
HTH
--

Cristian wrote

> Hi everyone,
>
> I need to write a loop in SPSS syntax. I know how to write it in SAS. Can
> someone tell me how to write the following in SPSS syntax. Writing nested
> loops with a BY statement is what is confusing me.
>
> SAS/IML Syntax
> START Delta_Epsilon;
> cnt =0;
> by1 =.02;
> by2 =.02;
> end1=2;
> end2=2;
> do delta=by1 to end1 by by1 ; /* impacts kurtosis */
> do epsilon=-end2 to end2 by by2; /* impacts skewness */
> cnt=cnt+1;
> T=sinh(delta*arsinh(Raw)-epsilon);
> end;
> end;
> FINISH Delta_Epsilon;
>
>
> Much thanks,
>
> Cristian
>
>
>
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

Jon Peck
LOOP accepts fractional arguments.

On Thu, Feb 1, 2018 at 5:40 PM, David Marso <[hidden email]> wrote:
SPSS has a LOOP statement.
It takes integer arguments so you will have to fiddle with division.
HTH
--

Cristian wrote
> Hi everyone,
>
> I need to write a loop in SPSS syntax. I know how to write it in SAS. Can
> someone tell me how to write the following in SPSS syntax. Writing nested
> loops with a BY statement is what is confusing me.
>
> SAS/IML Syntax
>               START Delta_Epsilon;
>                       cnt =0;
>                       by1 =.02;
>                       by2 =.02;
>                       end1=2;
>                       end2=2;
>                       do delta=by1 to end1 by by1 ; /* impacts kurtosis */
>                               do epsilon=-end2 to end2 by by2; /* impacts skewness */
>                                       cnt=cnt+1;
>                                       T=sinh(delta*arsinh(Raw)-epsilon);
>                               end;
>                       end;
>               FINISH Delta_Epsilon;
>
>
> Much thanks,
>
> Cristian
>
>
>
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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



--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

Kirill Orlov
In reply to this post by David Marso
In MATRIX loop needs integer arguments. Off-matrix loop accepts fractional ones.

02.02.2018 3:40, David Marso пишет:
SPSS has a LOOP statement.
It takes integer arguments so you will have to fiddle with division.
HTH
--


===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

Javier Figueroa
Hello!!!

I hope I can help you with this example that I buy, there are many ways to create loops with SPSS, this is one using the VECTOR command

/ * here I go through a series of variables 1 to 20 and I count how many are with information,
/ * Then I check the variable p1 for a total and compare it with the path of the variables.
/ * I HOPE IT HELPS YOU.


/ * definition of the variable to be traversed.

VECTOR P2=P2$01 TO P2$20.

/ * initialization of variables.

calculate P2_contador_1 = 0.
calculate P2_total_2 = 0.

compute P2_contador_1=0.
compute P2_total_2=0.

/* Loop

LOOP #J=1 TO 20.
-            compute P2_total_2=P1.
-            DO IF NOT MISSING(P2(#J)).
-                     IF P2(#J)>=1 P2_contador_1=P2_contador_1+1.
-            END IF.
END LOOP.
EXECUTE.

/* condiciones / VERIFICACIONES DE RECORRIDO.

DO IF P2_total_2<>P2_contador_1.
      PRINT / 'Cuest.--> ' CORRELATIVO ' Paquete --> ' Paquete ' # Miembros familia -- > ' P2_contador_1 ' no igual al total  ---> '  P2_total_2.
END IF.
EXECUTE.

Javier Figueroa
Analisis y procesamiento de datos independiente
Ciudad de Guatemala
4762-7804



2018-02-02 4:28 GMT-06:00 Kirill Orlov <[hidden email]>:
In MATRIX loop needs integer arguments. Off-matrix loop accepts fractional ones.

02.02.2018 3:40, David Marso пишет:
SPSS has a LOOP statement.
It takes integer arguments so you will have to fiddle with division.
HTH
--


===================== 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



--
Javier Figueroa
Procesamiento y Análisis de bases de datos
Cel: 5927-4748 / 4970-1940
Casa: 2289-0184

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

David Marso
Administrator
Sorry can't resist.
Your code can be rewritten quite concisely:

VECTOR P2=P2$01 TO P2$20.
COMPUTE P2_total_2=P1.

/* Loop
LOOP #J=1 TO 20.
+  COMPUTE P2_contador_1=SUM( P2_contador_1, P2(#J) GE 1 ) .
END LOOP.






Javier Figueroa wrote

> Hello!!!
>
> I hope I can help you with this example that I buy, there are many ways to
> create loops with SPSS, this is one using the VECTOR command
>
> / * here I go through a series of variables 1 to 20 and I count how many
> are with information,
> / * Then I check the variable p1 for a total and compare it with the path
> of the variables.
> / * I HOPE IT HELPS YOU.
>
>
> / * definition of the variable to be traversed.
>
> VECTOR P2=P2$01 TO P2$20.
>
> / * initialization of variables.
>
> calculate P2_contador_1 = 0.
> calculate P2_total_2 = 0.
>
> compute P2_contador_1=0.
> compute P2_total_2=0.
>
> /* Loop
>
> LOOP #J=1 TO 20.
> -            compute P2_total_2=P1.
> -            DO IF NOT MISSING(P2(#J)).
> -                     IF P2(#J)>=1 P2_contador_1=P2_contador_1+1.
> -            END IF.
> END LOOP.
> EXECUTE.
>
> /* condiciones / VERIFICACIONES DE RECORRIDO.
>
> DO IF P2_total_2<>P2_contador_1.
>       PRINT / 'Cuest.--> ' CORRELATIVO ' Paquete --> ' Paquete ' #
> Miembros
> familia -- > ' P2_contador_1 ' no igual al total  ---> '  P2_total_2.
> END IF.
> EXECUTE.
>
> Javier Figueroa
> Analisis y procesamiento de datos independiente
> Ciudad de Guatemala
> 4762-7804
>
>
>
> 2018-02-02 4:28 GMT-06:00 Kirill Orlov &lt;

> kior@

> &gt;:
>
>> In MATRIX loop needs integer arguments. Off-matrix loop accepts
>> fractional
>> ones.
>>
>> 02.02.2018 3:40, David Marso пишет:
>>
>> SPSS has a LOOP statement.
>> It takes integer arguments so you will have to fiddle with division.
>> HTH
>> --
>>
>>
>>
>> ===================== To manage your subscription to SPSSX-L, send a
>> message to

> LISTSERV@.UGA

>  (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
>>
>
>
>
> --
>
> *Javier FigueroaProcesamiento y Análisis de bases de datos*
> *Cel: 5927-4748 / 4970-1940*
>
>
> *Casa: 2289-0184*
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

David Marso
Administrator
In reply to this post by Jon Peck
I have become so brainwashed by the MATRIX language that I spaced on that.  I
don't believe I have typically used LOOP other than to index VECTORs.  Must
log this.


Jon Peck wrote
> LOOP accepts fractional arguments.
>
> On Thu, Feb 1, 2018 at 5:40 PM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> SPSS has a LOOP statement.
>> It takes integer arguments so you will have to fiddle with division.
>> HTH
>> --
>>
>> Cristian wrote
>> > Hi everyone,
>> >
>> > I need to write a loop in SPSS syntax. I know how to write it in SAS.
>> Can
>> > someone tell me how to write the following in SPSS syntax. Writing
>> nested
>> > loops with a BY statement is what is confusing me.
>> >
>> > SAS/IML Syntax
>> >               START Delta_Epsilon;
>> >                       cnt =0;
>> >                       by1 =.02;
>> >                       by2 =.02;
>> >                       end1=2;
>> >                       end2=2;
>> >                       do delta=by1 to end1 by by1 ; /* impacts kurtosis
>> */
>> >                               do epsilon=-end2 to end2 by by2; /*
>> impacts skewness */
>> >                                       cnt=cnt+1;
>> >                                      
>> T=sinh(delta*arsinh(Raw)-epsilon);
>> >                               end;
>> >                       end;
>> >               FINISH Delta_Epsilon;
>> >
>> >
>> > Much thanks,
>> >
>> > Cristian
>> >
>> >
>> >
>> > --
>> > Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>> >
>> > =====================
>> > To manage your subscription to SPSSX-L, send a message to
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>>
>>
>>
>>
>>
>> -----
>> 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?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
>
>
>
> --
> Jon K Peck

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

Javier Figueroa
It really is a really good game, programmed and approved for a long time, but his attention is directed to me and I am able to do it, (IT IS JUST AN EXAMPLE) and it is really for cristian (Cristian gugiu.2@osu. edu) that requests support in how can WRITE a loop with SPSS, he mentions that he can write it in SAS and not in SPSS, thanks for his comments.

Cristian note.

Hi everyone,

I need to write a loop in SPSS syntax. I know how to write it in SAS. Can
someone tell me how to write the following in SPSS syntax. Writing nested
loops with a BY statement is what is confusing me.

SAS/IML Syntax
                START Delta_Epsilon;
                        cnt =0;
                        by1 =.02;
                        by2 =.02;
                        end1=2;
                        end2=2;
                        do delta=by1 to end1 by by1 ; /* impacts kurtosis */
                                do epsilon=-end2 to end2 by by2; /* impacts skewness */
                                        cnt=cnt+1;
                                        T=sinh(delta*arsinh(Raw)-epsilon);
                                end;
                        end;
                FINISH Delta_Epsilon;


Much thanks,

Cristian



2018-02-02 9:43 GMT-06:00 David Marso <[hidden email]>:
I have become so brainwashed by the MATRIX language that I spaced on that.  I
don't believe I have typically used LOOP other than to index VECTORs.  Must
log this.


Jon Peck wrote
> LOOP accepts fractional arguments.
>
> On Thu, Feb 1, 2018 at 5:40 PM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> SPSS has a LOOP statement.
>> It takes integer arguments so you will have to fiddle with division.
>> HTH
>> --
>>
>> Cristian wrote
>> > Hi everyone,
>> >
>> > I need to write a loop in SPSS syntax. I know how to write it in SAS.
>> Can
>> > someone tell me how to write the following in SPSS syntax. Writing
>> nested
>> > loops with a BY statement is what is confusing me.
>> >
>> > SAS/IML Syntax
>> >               START Delta_Epsilon;
>> >                       cnt =0;
>> >                       by1 =.02;
>> >                       by2 =.02;
>> >                       end1=2;
>> >                       end2=2;
>> >                       do delta=by1 to end1 by by1 ; /* impacts kurtosis
>> */
>> >                               do epsilon=-end2 to end2 by by2; /*
>> impacts skewness */
>> >                                       cnt=cnt+1;
>> >
>> T=sinh(delta*arsinh(Raw)-epsilon);
>> >                               end;
>> >                       end;
>> >               FINISH Delta_Epsilon;
>> >
>> >
>> > Much thanks,
>> >
>> > Cristian
>> >
>> >
>> >
>> > --
>> > Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>> >
>> > =====================
>> > To manage your subscription to SPSSX-L, send a message to
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>>
>>
>>
>>
>>
>> -----
>> 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?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
>
>
>
> --
> Jon K Peck

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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



--
Javier Figueroa
Procesamiento y Análisis de bases de datos
Cel: 5927-4748 / 4970-1940
Casa: 2289-0184

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

Rich Ulrich
In reply to this post by David Marso

Ages ago, I saw examples where fractional increments gave "unexpected" results,

miscounting a loop by 1, owing to the fact that an increment of 0.02 (for example)

is only approximated by its binary representation. Whether that was in SPSS or

elsewhere, I took the lesson to heart - use integers for loop-counts.


Now, maybe SPSS uses some tiny epsilon to see if an increment matches the top value

(which is the solution that comes to mind) - I don't remember reading about that; but

users should still be reminded of that hazard for programming languages in general. 


--

Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of David Marso <[hidden email]>
Sent: Friday, February 2, 2018 10:43:39 AM
To: [hidden email]
Subject: Re: Looping is SPSS
 
I have become so brainwashed by the MATRIX language that I spaced on that.  I
don't believe I have typically used LOOP other than to index VECTORs.  Must
log this.


Jon Peck wrote
> LOOP accepts fractional arguments.
>
> On Thu, Feb 1, 2018 at 5:40 PM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> SPSS has a LOOP statement.
>> It takes integer arguments so you will have to fiddle with division.
>> HTH
>> --
>>
>> Cristian wrote
>> > Hi everyone,
>> >
>> > I need to write a loop in SPSS syntax. I know how to write it in SAS.
>> Can
>> > someone tell me how to write the following in SPSS syntax. Writing
>> nested
>> > loops with a BY statement is what is confusing me.
>> >
>> > SAS/IML Syntax
>> >               START Delta_Epsilon;
>> >                       cnt =0;
>> >                       by1 =.02;
>> >                       by2 =.02;
>> >                       end1=2;
>> >                       end2=2;
>> >                       do delta=by1 to end1 by by1 ; /* impacts kurtosis
>> */
>> >                               do epsilon=-end2 to end2 by by2; /*
>> impacts skewness */
>> >                                       cnt=cnt+1;
>> >                                     
>> T=sinh(delta*arsinh(Raw)-epsilon);
>> >                               end;
>> >                       end;
>> >               FINISH Delta_Epsilon;
>> >
>> >
>> > Much thanks,
>> >
>> > Cristian
>> >
>> >
>> >
>> > --
>> > Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>> >
>> > =====================
>> > To manage your subscription to SPSSX-L, send a message to
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>>
>>
>>
>>
>>
>> -----
>> 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?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
>
>
>
> --
> Jon K Peck

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

David Marso
Administrator
In reply to this post by David Marso
From Here: I am not sure what happens with T and cnt in this...
presumably it is something special with SAS IML...
Note that SPSS does not implement sinh or arsinh in the
COMPUTE functions so you will have to roll your own.
I'm surprised nobody has jumped on that.

CHECK MY MATH AND USE AT YOUR OWN DISCRETION.
Good Luck.
https://en.wikipedia.org/wiki/Hyperbolic_function

LOOP delta=0 to 2 by .02.
LOOP epsilon= -2 to 2 by .02.
COMMENT T=sinh(delta*arsinh(Raw)-epsilon).
COMPUTE x=Raw.
COMPUTE arsinX=LN( x + SQRT( x*x+1)).
COMPUTE x2=delta*arsinX-epsilon.
COMPUTE sinhX2=(EXP(x2)-EXP(-x2) )/2.
COMPUTE T=sinhX2.
END LOOP.
END LOOP.

Substituting I get:

COMPUTE T=.5*(EXP(   delta *LN( Raw + SQRT( Raw*Raw+1))-epsilon)
             -EXP( -(delta *LN( Raw + SQRT( Raw*Raw+1))-epsilon)) )/2.


SAS/IML Syntax
                START Delta_Epsilon;
                        cnt =0;
                        by1 =.02;
                        by2 =.02;
                        end1=2;
                        end2=2;
                        do delta=by1 to end1 by by1 ; /* impacts kurtosis */
                                do epsilon=-end2 to end2 by by2; /* impacts
skewness */
                                        cnt=cnt+1;
                                        T=sinh(delta*arsinh(Raw)-epsilon);
                                end;
                        end;
                FINISH Delta_Epsilon;



David Marso wrote

> I have become so brainwashed by the MATRIX language that I spaced on that.
> I
> don't believe I have typically used LOOP other than to index VECTORs.
> Must
> log this.
>
>
> Jon Peck wrote
>> LOOP accepts fractional arguments.
>>
>> On Thu, Feb 1, 2018 at 5:40 PM, David Marso &lt;
>
>> david.marso@
>
>> &gt; wrote:
>>
>>> SPSS has a LOOP statement.
>>> It takes integer arguments so you will have to fiddle with division.
>>> HTH
>>> --
>>>
>>> Cristian wrote
>>> > Hi everyone,
>>> >
>>> > I need to write a loop in SPSS syntax. I know how to write it in SAS.
>>> Can
>>> > someone tell me how to write the following in SPSS syntax. Writing
>>> nested
>>> > loops with a BY statement is what is confusing me.
>>> >
>>> > SAS/IML Syntax
>>> >               START Delta_Epsilon;
>>> >                       cnt =0;
>>> >                       by1 =.02;
>>> >                       by2 =.02;
>>> >                       end1=2;
>>> >                       end2=2;
>>> >                       do delta=by1 to end1 by by1 ; /* impacts
>>> kurtosis
>>> */
>>> >                               do epsilon=-end2 to end2 by by2; /*
>>> impacts skewness */
>>> >                                       cnt=cnt+1;
>>> >                                      
>>> T=sinh(delta*arsinh(Raw)-epsilon);
>>> >                               end;
>>> >                       end;
>>> >               FINISH Delta_Epsilon;
>>> >
>>> >
>>> > Much thanks,
>>> >
>>> > Cristian
>>> >
>>> >
>>> >
>>> > --
>>> > Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>> >
>>> > =====================
>>> > To manage your subscription to SPSSX-L, send a message to
>>>
>>> > LISTSERV@.UGA
>>>
>>> >  (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
>>>
>>>
>>>
>>>
>>>
>>> -----
>>> 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?"
>>> --
>>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>>
>>> =====================
>>> To manage your subscription to SPSSX-L, send a message to
>>>
>
>> LISTSERV@.UGA
>
>>  (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
>>>
>>
>>
>>
>> --
>> Jon K Peck
>
>> jkpeck@
>
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (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
>
>
>
>
>
> -----
> 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?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

Jon Peck
In reply to this post by Rich Ulrich
It depends on what you expect :-)  Floating point arithmetic means that fractional values might not have an exact representation.  For example, 0.02 as a float is approximately
0.0200000000000000004163336342344337026589
so sometimes you have to take this into account.  For LOOP, you might just slightly vary the upper limit if this might be a problem.

This is intrinsic to floating point hardware.

On Fri, Feb 2, 2018 at 11:21 AM, Rich Ulrich <[hidden email]> wrote:

Ages ago, I saw examples where fractional increments gave "unexpected" results,

miscounting a loop by 1, owing to the fact that an increment of 0.02 (for example)

is only approximated by its binary representation. Whether that was in SPSS or

elsewhere, I took the lesson to heart - use integers for loop-counts.


Now, maybe SPSS uses some tiny epsilon to see if an increment matches the top value

(which is the solution that comes to mind) - I don't remember reading about that; but

users should still be reminded of that hazard for programming languages in general. 


--

Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of David Marso <[hidden email]>
Sent: Friday, February 2, 2018 10:43:39 AM
To: [hidden email]
Subject: Re: Looping is SPSS
 
I have become so brainwashed by the MATRIX language that I spaced on that.  I
don't believe I have typically used LOOP other than to index VECTORs.  Must
log this.


Jon Peck wrote
> LOOP accepts fractional arguments.
>
> On Thu, Feb 1, 2018 at 5:40 PM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> SPSS has a LOOP statement.
>> It takes integer arguments so you will have to fiddle with division.
>> HTH
>> --
>>
>> Cristian wrote
>> > Hi everyone,
>> >
>> > I need to write a loop in SPSS syntax. I know how to write it in SAS.
>> Can
>> > someone tell me how to write the following in SPSS syntax. Writing
>> nested
>> > loops with a BY statement is what is confusing me.
>> >
>> > SAS/IML Syntax
>> >               START Delta_Epsilon;
>> >                       cnt =0;
>> >                       by1 =.02;
>> >                       by2 =.02;
>> >                       end1=2;
>> >                       end2=2;
>> >                       do delta=by1 to end1 by by1 ; /* impacts kurtosis
>> */
>> >                               do epsilon=-end2 to end2 by by2; /*
>> impacts skewness */
>> >                                       cnt=cnt+1;
>> >                                     
>> T=sinh(delta*arsinh(Raw)-epsilon);
>> >                               end;
>> >                       end;
>> >               FINISH Delta_Epsilon;
>> >
>> >
>> > Much thanks,
>> >
>> > Cristian
>> >
>> >
>> >
>> > --
>> > Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>> >
>> > =====================
>> > To manage your subscription to SPSSX-L, send a message to
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>>
>>
>>
>>
>>
>> -----
>> 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?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
>
>
>
> --
> Jon K Peck

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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



--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

David Marso
Administrator
In reply to this post by David Marso
Put a bow/ribbon on it, dumping T into a file:


DEFINE !Delta_Epsilon ( !POS !CHAREND(">") /!POS !TOKENS(1)
                       /!POS !TOKENS(1) !DEFAULT(2)/!POS !TOKENS(1)
!DEFAULT(.02)
                       /!POS !CMDEND  
!DEFAULT('C:\temp\Delta_Epsilon.sav') )
LOOP delta=0 TO !3 BY !4.
+  LOOP epsilon= -!3  TO !3  by !4.
+    COMPUTE !2=.5*(EXP(   delta *LN( !1 + SQRT( !1*!1+1))-epsilon)
                   -EXP( -(delta *LN( !1 + SQRT( !1*!1+1))-epsilon)) )/2.
+    XSAVE OUTFILE !QUOTE( !5)   / KEEP delta epsilon !1 !2.
+  END LOOP.
END LOOP.

!ENDDEFINE.

DATA LIST FREE / raw.
BEGIN DATA
.5 .75 1 2
END DATA.
!Delta_Epsilon raw > Delta_Epsilon.
EXECUTE.
GET FILE ='C:\temp\Delta_Epsilon.sav'.

Could Call it using:
!Delta_Epsilon raw > Delta_Epsilon  2 .02 'C:\temp\Delta_Epsilon.sav'.





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Looping is SPSS

David Marso
Administrator
Oops get rid of either .5* or /2 in the equation.
David Marso wrote
Put a bow/ribbon on it, dumping T into a file: DEFINE !Delta_Epsilon ( !POS !CHAREND(">") /!POS !TOKENS(1) /!POS !TOKENS(1) !DEFAULT(2)/!POS !TOKENS(1) !DEFAULT(.02) /!POS !CMDEND !DEFAULT('C:\temp\Delta_Epsilon.sav') ) LOOP delta=0 TO !3 BY !4. + LOOP epsilon= -!3 TO !3 by !4. + COMPUTE !2=.5*(EXP( delta *LN( !1 + SQRT( !1*!1+1))-epsilon) -EXP( -(delta *LN( !1 + SQRT( !1*!1+1))-epsilon)) )/2. + XSAVE OUTFILE !QUOTE( !5) / KEEP delta epsilon !1 !2. + END LOOP. END LOOP. !ENDDEFINE. DATA LIST FREE / raw. BEGIN DATA .5 .75 1 2 END DATA. !Delta_Epsilon raw > Delta_Epsilon. EXECUTE. GET FILE ='C:\temp\Delta_Epsilon.sav'. Could Call it using: !Delta_Epsilon raw > Delta_Epsilon 2 .02 'C:\temp\Delta_Epsilon.sav'. ----- 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?" -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== 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
Do
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?"


Sent from the SPSSX Discussion mailing list archive at Nabble.com.
===================== 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
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?"