new variable syntax trouble

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

new variable syntax trouble

Buhi, Eric
Banned User
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: new variable syntax trouble

Oliver, Richard
do if schoolid=1.
compute newvar=2.5.
else if schoolid=2.
compute newvar=0.
...
else.
[condition]
end if.

________________________________

From: SPSSX(r) Discussion on behalf of Buhi, Eric
Sent: Fri 10/24/2008 11:18 AM
To: [hidden email]
Subject: new variable syntax trouble



I would like to assign a score to cases in my dataset which share a
common element (in my situation, they go to the same school). Do you
have any sample syntax to show me how to write an "if-then syntax
command" for creating this new variable? That is, I want to the syntax
to read something like this:



For new variable ... if schoolID = 1 then newVAR = 2.5, if schoolID = 2
then newVAR = 0, etc.



Thanks,

Eric





Eric R. Buhi, MPH, PhD, CHES

Assistant Professor

Department of Community and Family Health

College of Public Health

University of South Florida

13201 Bruce B. Downs Blvd., MDC 56

Tampa, Florida 33612

Phone: 813-974-5290

Fax: 813-974-5172

[hidden email]



Did you know?

* USF is one of only three Florida public universities classified by the
Carnegie Foundation in the top tier of research universities.

* USF is the ninth largest public university in the nation.

* USF is one of 39 U.S. public colleges and universities (the only one
in Florida) classified by the Carnegie Foundation as "Community
Engaged."



=======
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: new variable syntax trouble

Melissa Ives
How about...
Recode schoolid (1=2.5)(2=0)... Into newvar.


Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Oliver, Richard
Sent: Friday, October 24, 2008 11:43 AM
To: [hidden email]
Subject: Re: [SPSSX-L] new variable syntax trouble

do if schoolid=1.
compute newvar=2.5.
else if schoolid=2.
compute newvar=0.
...
else.
[condition]
end if.

________________________________

From: SPSSX(r) Discussion on behalf of Buhi, Eric
Sent: Fri 10/24/2008 11:18 AM
To: [hidden email]
Subject: new variable syntax trouble



I would like to assign a score to cases in my dataset which share a common element (in my situation, they go to the same school). Do you have any sample syntax to show me how to write an "if-then syntax command" for creating this new variable? That is, I want to the syntax to read something like this:



For new variable ... if schoolID = 1 then newVAR = 2.5, if schoolID = 2 then newVAR = 0, etc.



Thanks,

Eric





Eric R. Buhi, MPH, PhD, CHES

Assistant Professor

Department of Community and Family Health

College of Public Health

University of South Florida

13201 Bruce B. Downs Blvd., MDC 56

Tampa, Florida 33612

Phone: 813-974-5290

Fax: 813-974-5172

[hidden email]



Did you know?

* USF is one of only three Florida public universities classified by the Carnegie Foundation in the top tier of research universities.

* USF is the ninth largest public university in the nation.

* USF is one of 39 U.S. public colleges and universities (the only one in Florida) classified by the Carnegie Foundation as "Community Engaged."



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

PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.

=====================
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: new variable syntax trouble

Hector Maletta
In reply to this post by Buhi, Eric
IF  (X=1) y=2.5.
IF  (X=2) y=0.
Etc.

However, if your schools are many, this could be tiresome to write on a
syntax file. You may use a number of shortcuts.
One of them (a no brainer) is writing the syntax in a series of columns of
an Excel worksheet by means of cut and paste. For instance, suppose you have
K schools. The characters IF(x= may be on the first K rows of column A; the
series of school IDs goes on column B, then characters )=y= on the first K
rows of column C; the series of K values assigned to the K schools on column
D, and a period (.) on each row of column E. Select all columns and choose
Format-Column-Autofit Selection, so that each column width is as narrow as
required to show their contents and no more. Highlight it all and copy to
your syntax file.
Hector
-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Buhi, Eric
Sent: 24 October 2008 14:18
To: [hidden email]
Subject: new variable syntax trouble

I would like to assign a score to cases in my dataset which share a
common element (in my situation, they go to the same school). Do you
have any sample syntax to show me how to write an "if-then syntax
command" for creating this new variable? That is, I want to the syntax
to read something like this:



For new variable ... if schoolID = 1 then newVAR = 2.5, if schoolID = 2
then newVAR = 0, etc.



Thanks,

Eric





Eric R. Buhi, MPH, PhD, CHES

Assistant Professor

Department of Community and Family Health

College of Public Health

University of South Florida

13201 Bruce B. Downs Blvd., MDC 56

Tampa, Florida 33612

Phone: 813-974-5290

Fax: 813-974-5172

[hidden email]



Did you know?

* USF is one of only three Florida public universities classified by the
Carnegie Foundation in the top tier of research universities.

* USF is the ninth largest public university in the nation.

* USF is one of 39 U.S. public colleges and universities (the only one
in Florida) classified by the Carnegie Foundation as "Community
Engaged."




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: new variable syntax trouble

Art Kendall
In reply to this post by Buhi, Eric
With only 2 possible situations mentioned  it is is a little unclear
what you are asking
If you want certain schools to be assigned completely arbitrary values
try something like
recode schoolid (1,3,5=2.5) (2=0) (21 thru 33 =3.3)... (else=-1) into
newVAR.

another way to do the same thing
do if schoolid eq 1.
compute newvar=2.5
else if schoolid  eq 2.
compute  newvar=0.
else if range(newvar, 21,33)
compute newvar=3.3)
else if ...
else if...
else.
compute new var=-1.
end if.

It is also possible that you could create 2 files sorted by schoolid.
1 with all the students including a schoolid e.g., "students" and 1 with
schoolid and a single  newvar value for each e.g."school".
match files
 file=students /table= school /by schoolid.

If none of these are helpful please re-post with more detail

Art Kendall
Social Research Consultants



Buhi, Eric wrote:

> I would like to assign a score to cases in my dataset which share a
> common element (in my situation, they go to the same school). Do you
> have any sample syntax to show me how to write an "if-then syntax
> command" for creating this new variable? That is, I want to the syntax
> to read something like this:
>
>
>
> For new variable ... if schoolID = 1 then newVAR = 2.5, if schoolID = 2
> then newVAR = 0, etc.
>
>
>
> Thanks,
>
> Eric
>
>
>
>
>
> Eric R. Buhi, MPH, PhD, CHES
>
> Assistant Professor
>
> Department of Community and Family Health
>
> College of Public Health
>
> University of South Florida
>
> 13201 Bruce B. Downs Blvd., MDC 56
>
> Tampa, Florida 33612
>
> Phone: 813-974-5290
>
> Fax: 813-974-5172
>
> [hidden email]
>
>
>
> Did you know?
>
> * USF is one of only three Florida public universities classified by the
> Carnegie Foundation in the top tier of research universities.
>
> * USF is the ninth largest public university in the nation.
>
> * USF is one of 39 U.S. public colleges and universities (the only one
> in Florida) classified by the Carnegie Foundation as "Community
> Engaged."
>
>
>
> ===================
> 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
Reply | Threaded
Open this post in threaded view
|

Re: new variable syntax trouble

Buhi, Eric
Banned User
In reply to this post by Oliver, Richard
CONTENTS DELETED
The author has deleted this message.