CASESTOVARS when a variable is currently missing

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

CASESTOVARS when a variable is currently missing

Dennis Deck
Context:  Responses to an online survey are captured in a database.  The original database table stores a record for each response to each item on the survey. In SPSS I roll up the item responses for a particular time point into a single record using CASESTOVARS.  There are periodicl updates so over time we willl have multiple records for each individual.  

Problem:  There are a few items to which no respondent has yet responded to so CASESTOVARS fails to create these in the data set.  For now i must add them by brute force (I use a series of commands like "COMPUTE  VarX = $sysmis.") but would prefer a more elegant solution because I will have no warning when someone eventually completes these items. This COMPUTE will over write the actual responses.

Can anyone offer a solution?   I thought about adding a dummy set of records with all the items defined when i read the file and then remove the resulting dummy record after the CASESTOVARS but this would be awkward.  

Dennis Deck, PhD
RMC Research Corporation
111 SW Columbia Street, Suite 1200
Portland, Oregon 97201-5843
voice: 503-223-8248 x715
voice: 800-788-1887 x715
fax:  503-223-8248
[hidden email]

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

R: CASESTOVARS when a variable is currently missing

Luca Meyer
Hello Dennis,

Supposing you have a complete list of all possible items - that is
closed-answers structure - one suggestion would be that you build fake
answers before the CASESTOVAR and then delete the dummy user before going
forward with analysis. For instance, suppose you do not yet have answer for
item 5 at question 4. Assume also that you have respondent id going from 1
to 1000. Then in the original datafile (OLDRECORDS) I would insert something
like (untested syntax):

DATA LIST LIST/IDRESPONDENT IDQUESTION IDANSWER.
BEGIN DATA
9999 4 5
END DATA.

ADD FILES /FILE=OLDRECORDS /FILE=*.

Once I have run CASESTOVAR I would exclude idrespondent 9999 by

SELECT IF IDRESPONDENT<>9999.

Assuming question 4 allows for multiple responses, this should live me with
a dataset with a column for items 5 at question 4, although it will be
empty.

HTH,
Luca

Mr. Luca MEYER
Market research, data analysis & more
www.lucameyer.com - Tel: +39.339.495.00.21


-----Messaggio originale-----
Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di
Dennis Deck
Inviato: giovedì 17 gennaio 2008 4.11
A: [hidden email]
Oggetto: CASESTOVARS when a variable is currently missing

Context:  Responses to an online survey are captured in a database.  The
original database table stores a record for each response to each item on
the survey. In SPSS I roll up the item responses for a particular time point
into a single record using CASESTOVARS.  There are periodicl updates so over
time we willl have multiple records for each individual.

Problem:  There are a few items to which no respondent has yet responded to
so CASESTOVARS fails to create these in the data set.  For now i must add
them by brute force (I use a series of commands like "COMPUTE  VarX =
$sysmis.") but would prefer a more elegant solution because I will have no
warning when someone eventually completes these items. This COMPUTE will
over write the actual responses.

Can anyone offer a solution?   I thought about adding a dummy set of records
with all the items defined when i read the file and then remove the
resulting dummy record after the CASESTOVARS but this would be awkward.

Dennis Deck, PhD
RMC Research Corporation
111 SW Columbia Street, Suite 1200
Portland, Oregon 97201-5843
voice: 503-223-8248 x715
voice: 800-788-1887 x715
fax:  503-223-8248
[hidden email]

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

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.5/1228 - Release Date: 16/01/2008
9.01


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.5/1228 - Release Date: 16/01/2008
9.01

=====================
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:R: CASESTOVARS when a variable is currently missing

Jerabek Jindrich
Hello Denis,


You could use NUMERIC instead of "COMPUTE  VarX = $sysmis."
NUMERIC VarX (F10.2) creates new variable VarX, when the variable is already present in dataset it does not do anything
 and issues a warning "variable VarX already exists".


Another way is to create an empty datafile that has all variables you need but no cases. Create a datafile with casestovars and "brute force" as you did, delete all cases and save as MyVariableStructure.
And when you will need to add variables for items not answered, just merge the file with your data:
ADD
/file = "MyVariableStructure"
/file = "MyDataSet".


HTH
Jindra



> ------------ Původní zpráva ------------
> Od: Luca Meyer <[hidden email]>
> Předmět: R: CASESTOVARS when a variable is currently missing
> Datum: 17.1.2008 08:01:39
> ----------------------------------------
> Hello Dennis,
>
> Supposing you have a complete list of all possible items - that is
> closed-answers structure - one suggestion would be that you build fake
> answers before the CASESTOVAR and then delete the dummy user before going
> forward with analysis. For instance, suppose you do not yet have answer for
> item 5 at question 4. Assume also that you have respondent id going from 1
> to 1000. Then in the original datafile (OLDRECORDS) I would insert something
> like (untested syntax):
>
> DATA LIST LIST/IDRESPONDENT IDQUESTION IDANSWER.
> BEGIN DATA
> 9999 4 5
> END DATA.
>
> ADD FILES /FILE=OLDRECORDS /FILE=*.
>
> Once I have run CASESTOVAR I would exclude idrespondent 9999 by
>
> SELECT IF IDRESPONDENT<>9999.
>
> Assuming question 4 allows for multiple responses, this should live me with
> a dataset with a column for items 5 at question 4, although it will be
> empty.
>
> HTH,
> Luca
>
> Mr. Luca MEYER
> Market research, data analysis & more
> www.lucameyer.com - Tel: +39.339.495.00.21
>
>
> -----Messaggio originale-----
> Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di
> Dennis Deck
> Inviato: giovedì 17 gennaio 2008 4.11
> A: [hidden email]
> Oggetto: CASESTOVARS when a variable is currently missing
>
> Context:  Responses to an online survey are captured in a database.  The
> original database table stores a record for each response to each item on
> the survey. In SPSS I roll up the item responses for a particular time point
> into a single record using CASESTOVARS.  There are periodicl updates so over
> time we willl have multiple records for each individual.
>
> Problem:  There are a few items to which no respondent has yet responded to
> so CASESTOVARS fails to create these in the data set.  For now i must add
> them by brute force (I use a series of commands like "COMPUTE  VarX =
> $sysmis.") but would prefer a more elegant solution because I will have no
> warning when someone eventually completes these items. This COMPUTE will
> over write the actual responses.
>
> Can anyone offer a solution?   I thought about adding a dummy set of records
> with all the items defined when i read the file and then remove the
> resulting dummy record after the CASESTOVARS but this would be awkward.
>
> Dennis Deck, PhD
> RMC Research Corporation
> 111 SW Columbia Street, Suite 1200
> Portland, Oregon 97201-5843
> voice: 503-223-8248 x715
> voice: 800-788-1887 x715
> fax:  503-223-8248
> [hidden email]
>
> =======
> 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
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.5/1228 - Release Date: 16/01/2008
> 9.01
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.5/1228 - Release Date: 16/01/2008
> 9.01
>
> =====================
> 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: R: CASESTOVARS when a variable is currently missing

Albert-Jan Roskam
Hi Dennis,

> You could use NUMERIC instead of "COMPUTE  VarX =
> $sysmis."
> NUMERIC VarX (F10.2) creates new variable VarX, when
> the variable is already present in dataset it does
> not do anything
>  and issues a warning "variable VarX already
> exists".

===> Yep, that works, but I believe this is an error,
and not a warning. Therefore this method cannot be
used during batch processing (INCLUDE/INSERT, or the
Production Facility).

One different version of the 'dummy record' method is
to first create one 'master' record, then save this
little file somewhere (master.sav) and use the
following line on every new 'real' data file:
APPLY DICTIONARY FROM "d:\temp\master.sav" / NEWVARS.

This will create the new variables if they're not
present yet, but won't give you that ugly error nor
will it pollute your data with that dummy record. It
will also copy all value/var label definitions,
missing value definitions, and some more things.

Cheers!!
Albert-Jan


>
> Another way is to create an empty datafile that has
> all variables you need but no cases. Create a
> datafile with casestovars and "brute force" as you
> did, delete all cases and save as
> MyVariableStructure.
> And when you will need to add variables for items
> not answered, just merge the file with your data:
> ADD
> /file = "MyVariableStructure"
> /file = "MyDataSet".
>
>
> HTH
> Jindra
>
>
>
> > ------------ Původní zpráva ------------
> > Od: Luca Meyer <[hidden email]>
> > Předmět: R: CASESTOVARS when a variable is
> currently missing
> > Datum: 17.1.2008 08:01:39
> > ----------------------------------------
> > Hello Dennis,
> >
> > Supposing you have a complete list of all possible
> items - that is
> > closed-answers structure - one suggestion would be
> that you build fake
> > answers before the CASESTOVAR and then delete the
> dummy user before going
> > forward with analysis. For instance, suppose you
> do not yet have answer for
> > item 5 at question 4. Assume also that you have
> respondent id going from 1
> > to 1000. Then in the original datafile
> (OLDRECORDS) I would insert something
> > like (untested syntax):
> >
> > DATA LIST LIST/IDRESPONDENT IDQUESTION IDANSWER.
> > BEGIN DATA
> > 9999 4 5
> > END DATA.
> >
> > ADD FILES /FILE=OLDRECORDS /FILE=*.
> >
> > Once I have run CASESTOVAR I would exclude
> idrespondent 9999 by
> >
> > SELECT IF IDRESPONDENT<>9999.
> >
> > Assuming question 4 allows for multiple responses,
> this should live me with
> > a dataset with a column for items 5 at question 4,
> although it will be
> > empty.
> >
> > HTH,
> > Luca
> >
> > Mr. Luca MEYER
> > Market research, data analysis & more
> > www.lucameyer.com - Tel: +39.339.495.00.21
> >
> >
> > -----Messaggio originale-----
> > Da: SPSSX(r) Discussion
> [mailto:[hidden email]] Per conto di
> > Dennis Deck
> > Inviato: giovedì 17 gennaio 2008 4.11
> > A: [hidden email]
> > Oggetto: CASESTOVARS when a variable is currently
> missing
> >
> > Context:  Responses to an online survey are
> captured in a database.  The
> > original database table stores a record for each
> response to each item on
> > the survey. In SPSS I roll up the item responses
> for a particular time point
> > into a single record using CASESTOVARS.  There are
> periodicl updates so over
> > time we willl have multiple records for each
> individual.
> >
> > Problem:  There are a few items to which no
> respondent has yet responded to
> > so CASESTOVARS fails to create these in the data
> set.  For now i must add
> > them by brute force (I use a series of commands
> like "COMPUTE  VarX =
> > $sysmis.") but would prefer a more elegant
> solution because I will have no
> > warning when someone eventually completes these
> items. This COMPUTE will
> > over write the actual responses.
> >
> > Can anyone offer a solution?   I thought about
> adding a dummy set of records
> > with all the items defined when i read the file
> and then remove the
> > resulting dummy record after the CASESTOVARS but
> this would be awkward.
> >
> > Dennis Deck, PhD
> > RMC Research Corporation
> > 111 SW Columbia Street, Suite 1200
> > Portland, Oregon 97201-5843
> > voice: 503-223-8248 x715
> > voice: 800-788-1887 x715
> > fax:  503-223-8248
> > [hidden email]
> >
> > =======
> > 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
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.516 / Virus Database: 269.19.5/1228 -
> Release Date: 16/01/2008
> > 9.01
> >
> >
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.5.516 / Virus Database: 269.19.5/1228 -
> Release Date: 16/01/2008
> > 9.01
> >
> > =====================
> > 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
>



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs

=====================
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: CASESTOVARS when a variable is currently missing

Melissa Ives
In reply to this post by Dennis Deck
Dennis,

Look into the /AUTOFIX=No and /FIXED subcommands in CASETOVARS.  It
allows you to specify which items are fixed (so would only need one
response) or not fixed (and would need to have all values calculated).

The AUTOFIX subcommand evaluates candidate variables and classifies them
as either fixed or as the source of a variable group.

An original variable that does not vary within the row group is
classified as a fixed variable and is copied into a single variable in
the new data file.

An original variable that does vary within the row group is classified
as the source of a variable group. It becomes a variable group in the
new data file.

The FIXED subcommand names the variables that should be copied from the
original data to the new data file.

CASESTOVARS assumes that variables named on the FIXED subcommand do not
vary within row groups in the original data. If they vary, a warning
message is generated and the command is executed.

Fixed variables appear as a single column in the new data file. Their
values are simply copied to the new file.

Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Dennis Deck
Sent: Wednesday, January 16, 2008 9:11 PM
To: [hidden email]
Subject: [SPSSX-L] CASESTOVARS when a variable is currently missing

Context:  Responses to an online survey are captured in a database.  The
original database table stores a record for each response to each item
on the survey. In SPSS I roll up the item responses for a particular
time point into a single record using CASESTOVARS.  There are periodicl
updates so over time we willl have multiple records for each individual.


Problem:  There are a few items to which no respondent has yet responded
to so CASESTOVARS fails to create these in the data set.  For now i must
add them by brute force (I use a series of commands like "COMPUTE  VarX
= $sysmis.") but would prefer a more elegant solution because I will
have no warning when someone eventually completes these items. This
COMPUTE will over write the actual responses.

Can anyone offer a solution?   I thought about adding a dummy set of
records with all the items defined when i read the file and then remove
the resulting dummy record after the CASESTOVARS but this would be
awkward.

Dennis Deck, PhD
RMC Research Corporation
111 SW Columbia Street, Suite 1200
Portland, Oregon 97201-5843
voice: 503-223-8248 x715
voice: 800-788-1887 x715
fax:  503-223-8248
[hidden email]

=======
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: CASESTOVARS when a variable is currently missing

Dennis Deck
In reply to this post by Dennis Deck
I had considered something like this but decided there had to be a better way.

Note that you can use /IN=Template on the ADD FILES to identify the "template" record(s)
Then filter out the template records by: SELECT IF (Template=0) .

Of everything i have thought of myself or heard about on the listserve,
Albert-jan Roskam's suggestion to use APPLY DICTIONARY appears to be the most elegant.
Think thats what I'll do.


-----Original Message-----
From: Luca Meyer [mailto:[hidden email]]
Sent: Wednesday, January 16, 2008 10:58 PM
Subject: R: CASESTOVARS when a variable is currently missing

Hello Dennis,

Supposing you have a complete list of all possible items - that is closed-answers structure - one suggestion would be that you build fake answers before the CASESTOVAR and then delete the dummy user before going forward with analysis. For instance, suppose you do not yet have answer for item 5 at question 4. Assume also that you have respondent id going from 1 to 1000. Then in the original datafile (OLDRECORDS) I would insert something like (untested syntax):

DATA LIST LIST/IDRESPONDENT IDQUESTION IDANSWER.
BEGIN DATA
9999 4 5
END DATA.

ADD FILES /FILE=OLDRECORDS /FILE=*.

Once I have run CASESTOVAR I would exclude idrespondent 9999 by

SELECT IF IDRESPONDENT<>9999.

Assuming question 4 allows for multiple responses, this should live me with a dataset with a column for items 5 at question 4, although it will be empty.

HTH,
Luca

Mr. Luca MEYER
Market research, data analysis & more
www.lucameyer.com - Tel: +39.339.495.00.21


-----Messaggio originale-----
Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di Dennis Deck
Inviato: giovedì 17 gennaio 2008 4.11
A: [hidden email]
Oggetto: CASESTOVARS when a variable is currently missing

Context:  Responses to an online survey are captured in a database.  The original database table stores a record for each response to each item on the survey. In SPSS I roll up the item responses for a particular time point into a single record using CASESTOVARS.  There are periodicl updates so over time we willl have multiple records for each individual.

Problem:  There are a few items to which no respondent has yet responded to so CASESTOVARS fails to create these in the data set.  For now i must add them by brute force (I use a series of commands like "COMPUTE  VarX =
$sysmis.") but would prefer a more elegant solution because I will have no warning when someone eventually completes these items. This COMPUTE will over write the actual responses.

Can anyone offer a solution?   I thought about adding a dummy set of records
with all the items defined when i read the file and then remove the resulting dummy record after the CASESTOVARS but this would be awkward.

Dennis Deck, PhD
RMC Research Corporation
111 SW Columbia Street, Suite 1200
Portland, Oregon 97201-5843
voice: 503-223-8248 x715
voice: 800-788-1887 x715
fax:  503-223-8248
[hidden email]

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

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.5/1228 - Release Date: 16/01/2008
9.01


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.5/1228 - Release Date: 16/01/2008
9.01

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