Advice for Simplifying Two-line Syntax?

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

Advice for Simplifying Two-line Syntax?

elle lists

I’m correcting product names and plugging-in product numbers in a data set by using the IF statement and two conditions based on “Location” and “OldProductTitle”.  (Location is used to verify the product title as variations occur throughout the data set because the info has been entered inconsistently.) The two-line syntax works (shown below) but is there a way to condense the two or achieve the same effect in more efficient manner as the corrections number over 400 (which means 800 syntax lines)?  I’d also like to maintain working with strings as this situation is likely to reoccur.  Many thanks for your advice.   ~elle

 

SYNTAX EXAMPLE

 

IF Location=’Riverside’ AND OldProductTitle=’McAfee 2012’ NewProductTitle=’McAfee Total Protection 2012—3 Users’.

IF Location=’Riverside’ AND NewProductTitle=’McAfee Total Protection 2012—3 Users’ ProductNo=’B005AAWYR2’.

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Advice for Simplifying Two-line Syntax?

Maguin, Eugene

Elle,

Yes, there may be a simpler way to do this using either the Table subcommand of the Match files command or the Update command. But there may not be enough gain to make it worthwhile. The problem is already having or being to make up file 2 very easily.

 

To use either you need to have two files. File 1 would look like

 

Location       OldProductTitle

Riverside     McAfee 2012

Etc.

 

File 2 would look like

 

Location     OldProductTitle     NewProductTitle                                    ProductNo

Riverside    McAfee 2012         McAfee Total Protection 2012—3 Users  B005AAWYR2

 

1)     Assume that NewProductTitle and ProductNo are not in File 1.

Match files file=file 1/table=file 2/by location oldproducttitle.

 

2)     Assume that NewProductTitle and ProductNo are already in File 1.

Update file=file 1/file=file 2/by location oldproducttitle.

 

Gene Maguin

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of elle
Sent: Friday, December 02, 2011 4:43 PM
To: [hidden email]
Subject: Advice for Simplifying Two-line Syntax?

 

I’m correcting product names and plugging-in product numbers in a data set by using the IF statement and two conditions based on “Location” and “OldProductTitle”.  (Location is used to verify the product title as variations occur throughout the data set because the info has been entered inconsistently.) The two-line syntax works (shown below) but is there a way to condense the two or achieve the same effect in more efficient manner as the corrections number over 400 (which means 800 syntax lines)?  I’d also like to maintain working with strings as this situation is likely to reoccur.  Many thanks for your advice.   ~elle

 

SYNTAX EXAMPLE

 

IF Location=’Riverside’ AND OldProductTitle=’McAfee 2012’ NewProductTitle=’McAfee Total Protection 2012—3 Users’.

IF Location=’Riverside’ AND NewProductTitle=’McAfee Total Protection 2012—3 Users’ ProductNo=’B005AAWYR2’.

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Advice for Simplifying Two-line Syntax?

David Marso
Administrator
In reply to this post by elle lists
Build 2 additional files A.sav, B.sav
  A.sav: sorted by KEY VARIABLES [location and OldProductTitle: with data field: NewProductTitle],
  B.sav: sorted by KEY VARIABLES [location and NewProductTitle: with data field: ProductNo].
CODE:
--
GET FILE "your master file.sav".
SORT CASES BY location OldProductTitle.
MATCH FILES / FILE * /TABLE "A.sav" / BY location OldProductTitle.
SORT CASES BY location NewProductTitle.
MATCH FILES / FILE * /TABLE "B.sav" / BY location NewProductTitle.
FREQ NewProductTitle.

*MUCH EASIER than maintaining a 800 line syntax file!!!*
FWIW:  You *CAN NOT* condense your 2 liner into a one liner as it presumes computing 2 new variables.
OTOH:  Using the 2 tables will result in a low overhead aside from keeping your tables up to date.
These would best be stored in some sort of central data base!
HTH, David
--
elle lists wrote
I'm correcting product names and plugging-in product numbers in a data set
by using the IF statement and two conditions based on "Location" and
"OldProductTitle".  (Location is used to verify the product title as
variations occur throughout the data set because the info has been entered
inconsistently.) The two-line syntax works (shown below) but is there a way
to condense the two or achieve the same effect in more efficient manner as
the corrections number over 400 (which means 800 syntax lines)?  I'd also
like to maintain working with strings as this situation is likely to
reoccur.  Many thanks for your advice.   ~elle



SYNTAX EXAMPLE



IF Location='Riverside' AND OldProductTitle='McAfee 2012'
NewProductTitle='McAfee Total Protection 2012-3 Users'.

IF Location='Riverside' AND NewProductTitle='McAfee Total Protection 2012-3
Users' ProductNo='B005AAWYR2'.
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: Advice for Simplifying Two-line Syntax?

elle lists
Thank you, David Marso and Gene Maguin, for the brilliant idea (match files
instead of working by cases) and the additional suggestions (FWIW, OTOH)!
Comparing files is definitely easier (no 800-line syntax).  Thanks very much
for the help -  am off to setup the additional file.  ~elle

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Marso
Sent: Friday, December 02, 2011 10:33 AM
To: [hidden email]
Subject: Re: Advice for Simplifying Two-line Syntax?

Build 2 additional files A.sav, B.sav
  A.sav: sorted by KEY VARIABLES [location and OldProductTitle: with data
field: NewProductTitle],
  B.sav: sorted by KEY VARIABLES [location and NewProductTitle: with data
field: ProductNo].
CODE:
--
GET FILE "your master file.sav".
SORT CASES BY location OldProductTitle.
MATCH FILES / FILE * /TABLE "A.sav" / BY location OldProductTitle.
SORT CASES BY location NewProductTitle.
MATCH FILES / FILE * /TABLE "B.sav" / BY location NewProductTitle.
FREQ NewProductTitle.

*MUCH EASIER than maintaining a 800 line syntax file!!!*
FWIW:  You *CAN NOT* condense your 2 liner into a one liner as it presumes
computing 2 new variables.
OTOH:  Using the 2 tables will result in a low overhead aside from keeping
your tables up to date.
These would best be stored in some sort of central data base!
HTH, David
--

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Gene Maguin
Sent: Friday, December 02, 2011 10:32 AM
To: [hidden email]
Subject: Re: Advice for Simplifying Two-line Syntax?

Elle,
Yes, there may be a simpler way to do this using either the Table subcommand
of the Match files command or the Update command. But there may not be
enough gain to make it worthwhile. The problem is already having or being to
make up file 2 very easily.

To use either you need to have two files. File 1 would look like

Location       OldProductTitle
Riverside     McAfee 2012
Etc.

File 2 would look like

Location     OldProductTitle     NewProductTitle
ProductNo
Riverside    McAfee 2012         McAfee Total Protection 2012-3 Users
B005AAWYR2

1)      Assume that NewProductTitle and ProductNo are not in File 1.
Match files file=file 1/table=file 2/by location oldproducttitle.

2)      Assume that NewProductTitle and ProductNo are already in File 1.
Update file=file 1/file=file 2/by location oldproducttitle.

Gene Maguin

---
elle lists wrote

>
> I'm correcting product names and plugging-in product numbers in a data
> set by using the IF statement and two conditions based on "Location"
> and "OldProductTitle".  (Location is used to verify the product title
> as variations occur throughout the data set because the info has been
> entered
> inconsistently.) The two-line syntax works (shown below) but is there
> a way to condense the two or achieve the same effect in more efficient
> manner as the corrections number over 400 (which means 800 syntax
> lines)?  I'd also like to maintain working with strings as this
> situation is likely to
> reoccur.  Many thanks for your advice.   ~elle
>
>
>
> SYNTAX EXAMPLE
>
>
>
> IF Location='Riverside' AND OldProductTitle='McAfee 2012'
> NewProductTitle='McAfee Total Protection 2012-3 Users'.
>
> IF Location='Riverside' AND NewProductTitle='McAfee Total Protection
> 2012-3
> Users' ProductNo='B005AAWYR2'.
>


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Advice-for-Simplifying-Two-lin
e-Syntax-tp5043095p5043158.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
Reply | Threaded
Open this post in threaded view
|

Re: Advice for Simplifying Two-line Syntax?

Art Kendall
In reply to this post by elle lists
 I would be very unsure of using the approach of 800 lines of syntax.
First   AUTORECODE  location and OldProductTitle.  Save the template so it can be reapplied.  When you reapply the template to new data watch for new string values that were not found the first time around.
Second   RECODE the numeric variables from the AUTORECODE so that minor variations of spelling, casing, spacing etc. were collapsed into the same numeric variable. Copy the dictionary information from the first set of numeric values to the set produced by RECODE. (this assumes that you collapse variations into the best variation on the string)
Third   AGGREGATE cases by numeric location and numeric OldProductTitle with the first function for the new string variables.
Fourth   edit in 2 more columns with newproducttitle and productNo.
Fifth   print and proofread the new data set.
Sixth   use the new dataset as a table in MATCH CASES.

Art Kendall
Social Research Consultants

On 12/2/2011 4:42 PM, elle wrote:

I’m correcting product names and plugging-in product numbers in a data set by using the IF statement and two conditions based on “Location” and “OldProductTitle”.  (Location is used to verify the product title as variations occur throughout the data set because the info has been entered inconsistently.) The two-line syntax works (shown below) but is there a way to condense the two or achieve the same effect in more efficient manner as the corrections number over 400 (which means 800 syntax lines)?  I’d also like to maintain working with strings as this situation is likely to reoccur.  Many thanks for your advice.   ~elle

 

SYNTAX EXAMPLE

 

IF Location=’Riverside’ AND OldProductTitle=’McAfee 2012’ NewProductTitle=’McAfee Total Protection 2012—3 Users’.

IF Location=’Riverside’ AND NewProductTitle=’McAfee Total Protection 2012—3 Users’ ProductNo=’B005AAWYR2’.

 

 

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