Use of TEMPORARY with SELECT IF and COMPUTE

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

millesr
Posts: 1
Joined: Sun Mar 10, 2013 4:53 am

Use of TEMPORARY with SELECT IF and COMPUTE

Postby millesr » Sun Mar 10, 2013 5:01 am

Why does the following command not work. This is the actual output from the script, copied from the output screen.


TEMPORARY.
SELECT IF @10_a_package=1.
COMPUTE @11_cost_party=@11_cost*@12_b_exp.
EXECUTE.
.
TEMPORARY.
SELECT IF @10_a_package=1.
DESCRIPTIVES VARIABLES=@11_cost @11_cost_party /STATISTICS=MEAN STDDEV MIN MAX.

Text: @11_cost_party Command: DESCRIPTIVES
An undefined variable name, or a scratch or system variable was specified in a variable list which accepts only standard variables. Check spelling and verify the existence of this variable.
Execution of this command stops.

The series @11_cost_party is not being generated, though SPSS is not giving me an error to indicate it was not generated.

Many thanks,
Steve
JonPedersen
Posts: 119
Joined: Wed May 25, 2011 7:07 am
Contact:

Re: Use of TEMPORARY with SELECT IF and COMPUTE

Postby JonPedersen » Sun Mar 24, 2013 4:54 pm

Hi,
It does not work because of a common error in SPSS syntax: putting in EXECUTE all over the place.
Try:

Code: Select all

TEMPORARY. 
SELECT IF @10_a_package=1. 
COMPUTE @11_cost_party=@11_cost*@12_b_exp.  
DESCRIPTIVES VARIABLES=@11_cost @11_cost_party /STATISTICS=MEAN STDDEV MIN MAX.
The point being that in both your original syntax and the one above @11_cost_party is created as a temporary variable.
The moment you read the active dataset it is created, and then disappears without a trace. Since you had an execute between the first and second select if you did create the variable and then SPSS promptly forgot about it again. It is quite useful behavior, actually, especially for table creation.
best
Jon

Who is online

Users browsing this forum: No registered users and 2 guests

cron