Jon you raise a valid point about missing data.
Here is the example set of syntax with three cases added. Perhaps when the OP sees the syntax Hillel Vardi can tell us more specifically what the code was supposed to do and what to do when one of the arguments is missing. It would be interesting to hear back whether evx2 is what is needed. to borrow David's term my InterneTelepathy/ESP may be on the fritz. data list list /event (f1) timeev(f2) tfinal(f2)z(f5.2). begin data 1 1 5 -3.11 1 -1 5 2.10 0 1 1 1.00 1 6 5 -2.11 x 1 5 3.11 1 x 5 -2.58 1 1 x 2.58 3 1 5 -1.97 4 1 5 1.97 end data. missing values event (4). compute evx = 1*(event eq 1 and range(timeev,0,tfinal))+ 0*(event eq 0 or timeev gt tfinal). compute evx2 = event eq 1 and range(timeev,0,tfinal). compute pvalue=2*(1-cdf.norm(abs(z),0,1)). formats evx evx2(f1) pvalue(f5.3). frequencies variables= evx evx2 pvalue. list. Art Kendall Social Research ConsultantsOn 11/19/2012 1:39 PM, Jon K Peck wrote: Art,
Art Kendall
Social Research Consultants |
Administrator
|
Note: Won't this piece ALWAYS equal 0?
0*(event eq 0 or timeev gt tfinal). BTW: The term is ESPss ;-) --
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?" |
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: David Marso <[hidden email]> To: [hidden email], Date: 11/19/2012 01:43 PM Subject: Re: [SPSSX-L] sas to spss Sent by: "SPSSX(r) Discussion" <[hidden email]> Note: Won't this piece ALWAYS equal 0? >>>It will in SPSS, which I have always regretted, but I think that SAS evaluates 0 * missing as missing. 0*(event eq 0 or timeev gt tfinal). |
The SAS expression
evx = 1*(event eq 1 and 0 le timeev le tfinal)+0*(event eq 0 or timeev gt tfinal); has multiple redundancies (possibly by intention) The two logical expressions in parentheses are mutually exclusive. In SAS, evaluation of logical expressions produces 1 if true, else 0. Hence the multiplication by 1 or by 0 is unnecessary but might have been
written that way for emphasis to a human reader indicating what will be the resultant value if the corresponding side of the expression is true. The minimal SAS expression yielding the same results would be
evx = (event =1 and 0 le timeev le tfinal ); or conversely evx = not( event eq 0 or timeev gt tfinal ) ; ... Mark Miller On Mon, Nov 19, 2012 at 1:33 PM, Jon K Peck <[hidden email]> wrote:
|
What am I missing?
Would someone explain the reason (and meaning) of this piece, 0 le timeev le tfinal ? - It looks to me like (0 le timeev) should evaluate to TRUE, or 1, so that the second test becomes (1 le tfinal) ... which is, maybe, not desirable. There should be a clearer way to confirm that Event=1 and before the final time; and nothing is MISSING. I always group my logical expressions inside of parentheses, to avoid the chance that someone's rules for parsing may not be what I remember. SAS has to put EQ and LE as higher priority than AND and OR or else the simple, left-to-right processing would be weird for both expressions. -- Rich Ulrich Date: Mon, 19 Nov 2012 19:40:41 -0800 From: [hidden email] Subject: Re: sas to spss To: [hidden email] The SAS expression evx = 1*(event eq 1 and 0 le timeev le tfinal)+0*(event eq 0 or timeev gt tfinal); has multiple redundancies (possibly by intention) ... |
Rich,
Remember science/math/stat/econ classes where bracketing conditions were specified as lowbound < x < highbound (you choose the type of bounds) Well, SAS allows such compound expressions.
Hence (event eq 1 and 0 le timeev le tfinal) means just what you expect
Event = 0 and TimeEv > 0 and TimeEv <= TFinal It is a shorthand which I commonly espouse, because comparisons are more clear (to me at least), but I (myself)
generally use ample parentheses and white space to reinforce that. ... mark miller On Mon, Nov 19, 2012 at 9:45 PM, Rich Ulrich <[hidden email]> wrote:
|
Administrator
|
I would likely write it as
COMPUTE evx=event AND RANGE(TimeEv ,0,TFinal). --
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 David Marso
I wasn't sure my ESPss was working. That is why I asked the OP to check it.
yes that clause would always equal zero, that is why I suspected my ESPss was off. It is also why I included evx2 in the syntax. Art Kendall Social Research Consultants On 11/19/2012 3:41 PM, David Marso wrote: > Note: Won't this piece ALWAYS equal 0? > 0*(event eq 0 or timeev gt tfinal). > BTW: The term is ESPss ;-) > -- > > Art Kendall wrote >> Jon you raise a valid point about missing data. >> >> Here is the example set of syntax with three cases added. Perhaps >> when the OP >> sees the syntax Hillel >> Vardi can tell us more specifically what the code was >> supposed to do and what to do when one of the >> arguments is missing. >> It would be interesting to hear back whether evx2 is what is >> needed. >> >> � to borrow David's term my InterneTelepathy/ESP >> may be on the fritz.� >> >> data list list /event (f1) timeev(f2) tfinal(f2)z(f5.2). >> begin data >> 1� 1 5 -3.11 >> 1 -1 5� 2.10 >> 0� 1 1� 1.00 >> 1� 6 5 -2.11 >> x� 1 5� 3.11 >> 1� x 5 -2.58 >> 1� 1 x� 2.58 >> 3� 1 5 -1.97 >> 4� 1 5� 1.97 >> end data. >> missing values event (4). >> compute evx = >> � 1*(event eq 1 and range(timeev,0,tfinal))+ >> � 0*(event eq 0 or timeev gt tfinal). >> compute evx2 = event eq 1 and range(timeev,0,tfinal). >> compute pvalue=2*(1-cdf.norm(abs(z),0,1)). >> formats evx evx2(f1) pvalue(f5.3). >> frequencies variables= evx evx2 pvalue. >> list. >> >> Art Kendall >> Social Research Consultants >> On 11/19/2012 1:39 PM, Jon K Peck wrote: >> >> Art, >> >> >> The 0 term puzzled me, but the I wondered whether it is there to >> generate >> a missing result if anything in that term was missing, but then >> I noticed >> that the same variables are involved. � So what's the point? >> Jon Peck (no "h") aka Kim >> Senior Software Engineer, IBM >> >> peck@.ibm >> new phone: 720-342-5621 >> >> >> >> >> >> From: � � � >> � Art Kendall >> < >> Art@ >> > >> >> To: � � � >> � >> SPSSX-L@.uga >> , >> >> >> Date: � � � >> � 11/19/2012 11:33 AM >> >> Subject: � � >> � � Re: [SPSSX-L] >> sas to spss >> >> Sent by: � � >> � � "SPSSX(r) >> Discussion" < >> SPSSX-L@.uga >> > >> >> >> >> >> >> It is a lot of years since I used SAS, but try this >> check >> it against the semantic meaning of the variables. >> It appears that the code is calculating a dichotomous (logical) >> variable >> evx. where the value is 1 if event is true and timeev is within >> a specific >> range and otherwise it is zero. >> It is then find the probability of the absolute value of a z, >> subtracting >> that form one and doubling it. >> >> >> data list list /event (f1) timeev(f2) tfinal(f2)z(f5.2). >> begin data >> 1 1 5 -3.11 >> 1 -1 5 2.10 >> 0 1 1 1.00 >> 1 6 5 -2.11 >> end data. >> compute evx = >> 1*(event eq 1 and range(timeev,0,tfinal))+ >> 0*(event eq 0 or timeev gt tfinal). >> compute evx2 = event eq 1 and range(timeev,0,tfinal). >> compute pvalue=2*(1-cdf.norm(abs(z),0,1)). >> formats evx evx2(f1) pvalue(f5.3). >> frequencies variables= evx pvalue. >> list. >> >> >> >> >> Art Kendall >> Social Research Consultants >> >> On 11/18/2012 7:22 AM, Hillel Vardi wrote: >> >> Shalom >> >> I am adapting a sas macro to spss and have some difficulty with >> the sas >> code, can anyone help me translate the flowing code to spss >> >> evx = 1*(event eq 1 and 0 le timeev le tfinal)+0*(event eq 0 or >> timeev >> > tfinal); >> >> and the function >> >> pvalue=2*(1-probnorm(abs(z))); >> >> >> Hillel Vardi >> >> >> >> >> ===================== 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. > -- > View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Re-SPSSX-L-sas-to-spss-tp5716326p5716328.html > 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 > ===================== 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
Art Kendall
Social Research Consultants |
In reply to this post by Mark Miller
Thanks, I had not run into that convention.
I looks ad-hoc. It looks risky. I might use it but I hope that I would document it... I get the picture, though your translation has typos. -- Rich Ulrich Date: Mon, 19 Nov 2012 21:58:02 -0800 From: [hidden email] Subject: Re: sas to spss To: [hidden email] Rich, Remember science/math/stat/econ classes where bracketing conditions were specified as lowbound < x < highbound (you choose the type of bounds) Well, SAS allows such compound expressions.
Hence (event eq 1 and 0 le timeev le tfinal) means just what you expect
Event = 0 and TimeEv > 0 and TimeEv <= TFinal It is a shorthand which I commonly espouse, because comparisons are more clear (to me at least), but I (myself)
generally use ample parentheses and white space to reinforce that. ... mark miller ... |
Free forum by Nabble | Edit this page |