shorter syntax

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

shorter syntax

mils
Hi,

I would like to make this syntax shorter if possible. Any thoughts?


compute Q1_1=0.
if (Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshavey=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_A=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_B=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_C=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_D=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_E=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_F=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_G=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_H=1) Q1_1=1.
var lab Q1_1 'Esmya'.

compute Q1_2=0.
if (Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshavey=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_A=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_B=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_C=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_D=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_E=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_F=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_G=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_H=2) Q1_2=1.
var lab Q1_2 'Zoladex'.


Thanks!
mils
Reply | Threaded
Open this post in threaded view
|

Re: shorter syntax

Art Kendall
Long variable names are syntactically okay.  However, they really destroy readability.
type "variable labels." into a syntax window. put the cursor on that text. key <f1>.
or click <help> <topics>. Type "variable labels" into the text box. click >go>
 
There is a balance between carrying sufficient information in the variable to be mnemonic shorthand and including the variable label in the variable name.

do the same for "ANY".
something like this will work if the the variables are adjacent to each other. (untested)

compute Esyma = any(1,[variable list]).

if the the variables are adjacent to each other the variable list can use the TO convention, otherwise they need to be specified.

It is also possible to rearrange the variables so that they are adjacent.
Art Kendall
Social Research Consultants
On 5/11/2014 7:16 AM, mils [via SPSSX Discussion] wrote:
Hi,

I would like to make this syntax shorter if possible. Any thoughts?


compute Q1_1=0.
if (Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshavey=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_A=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_B=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_C=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_D=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_E=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_F=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_G=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_H=1) Q1_1=1.
var lab Q1_1 'Esmya'.

compute Q1_2=0.
if (Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshavey=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_A=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_B=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_C=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_D=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_E=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_F=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_G=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_H=2) Q1_2=1.
var lab Q1_2 'Zoladex'.


Thanks!
mils



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/shorter-syntax-tp5725958.html
To start a new topic under SPSSX Discussion, email [hidden email]
To unsubscribe from SPSSX Discussion, click here.
NAML

Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: shorter syntax

David Marso
Administrator
This post was updated on .
In reply to this post by mils
Maybe shorter variable names?
These as they are seem ridiculous/unreadable/perhaps use CamelCase as one possibility.
Aside from that, please consult the FM for VECTOR and LOOP.
Assuming your variables are contiguous (I'll call them blahblahblah TO blahblahblah_H).
If they are not then make them so (or list them out )!!!.

VECTOR Q1_(2).
LOOP #=1 TO 2.
COMPUTE Q1_(#)=ANY(#,blahblahblah TO blahblahblah_H).
END LOOP.

mils wrote
Hi,

I would like to make this syntax shorter if possible. Any thoughts?


compute Q1_1=0.
if (Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshavey=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_A=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_B=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_C=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_D=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_E=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_F=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_G=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_H=1) Q1_1=1.
var lab Q1_1 'Esmya'.

compute Q1_2=0.
if (Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshavey=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_A=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_B=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_C=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_D=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_E=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_F=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_G=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_H=2) Q1_2=1.
var lab Q1_2 'Zoladex'.


Thanks!
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: shorter syntax

Maguin, Eugene
In reply to this post by mils
You could count across the 1's across the variable list.
You could use the any function.
Gene Maguin

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of mils
Sent: Sunday, May 11, 2014 7:17 AM
To: [hidden email]
Subject: shorter syntax

Hi,

I would like to make this syntax shorter if possible. Any thoughts?


compute Q1_1=0.
if (Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshavey=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_A=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_B=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_C=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_D=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_E=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_F=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_G=1 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_H=1) Q1_1=1.
var lab Q1_1 'Esmya'.

compute Q1_2=0.
if (Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshavey=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_A=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_B=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_C=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_D=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_E=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_F=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_G=2 or
Q1_Whichproductsforthetreatmentofsymptomaticuterinefibroidshav_H=2) Q1_2=1.
var lab Q1_2 'Zoladex'.


Thanks!



-----
mils
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/shorter-syntax-tp5725958.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