seeking help with file restructure/or as output table

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

seeking help with file restructure/or as output table

thara vardhan-2
Dear List members

I would be grateful if any member could help me with restructuring my data
file. I have tried the restructure and aggregate function using menu in
SPSS but I am unable to findout where I am going wrong. I also tried to
use Ctables function but was only partially successful.

My data currently reads as follows:

Incident category               Person CNI      Events with LA

Drug detection                  xyz                     1

Break and enter                 xyz                     2

Malicious Damage                xyz                     1

I would like to create a data file or an output table as

Personcni     drug detection    Break and enter     Malicious damage
 xyz                     1                              2            1

I would be thankful if any member could help me with this problem.

regards
Thara Vardhan
Senior Statistician
Planning & Results
Organisation Review and Support
NSW Police
Tel: (02) 8835-8526


This message and any attachment is confidential and may
be privileged or otherwise protected from disclosure. If you
have received it by mistake, please let us know by reply
and then delete it from your system; you should not copy
the message or disclose its contents to anyone.
Reply | Threaded
Open this post in threaded view
|

Re: seeking help with file restructure/or as output table

Jamie Burnett-3
Hi, I am trying to create a new variable (PS_1A_weight) that will be
blank if another variable is blank (i.e. sysmis) and then will take
certain values if another two variables have certain values. However I
am running into trouble with the IF statement recognising sysmis? Can
anyone help?


IF PS_Class_1A=sysmis PS_1A_weight=sysmis.
IF DepSamplex1=0 & PS_Class_1A=1    PS_1A_weight=5.44460377758056.
IF DepSamplex1=0 & PS_Class_1A=2    PS_1A_weight=1.65515855164295.
IF DepSamplex1=0 & PS_Class_1A=3    PS_1A_weight=0.692010920683542.
IF DepSamplex1=0 & PS_Class_1A=4    PS_1A_weight=0.350248923534642.
IF DepSamplex1=0 & PS_Class_1A=5    PS_1A_weight=0.127587064425006.
IF DepSamplex1=1 & PS_Class_1A~=sysmis  PS_1A_weight=1.
Execute.


Thanks

Jamie


============================
This e-mail and all attachments it may contain is confidential and intended solely for the use of the individual to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Ipsos MORI and its associated companies. If you are not the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, printing, forwarding or copying of this e-mail is strictly prohibited. Please contact the sender if you have received this e-mail in error.

Market & Opinion Research International Ltd , Registered in England and Wales No. 948470 , 79-81 Borough Road , London SE1 1FY, United Kingdom, Email: [hidden email]
============================
Reply | Threaded
Open this post in threaded view
|

Re: seeking help with file restructure/or as output table

Richard Ristow
In reply to this post by thara vardhan-2
At 02:55 AM 8/23/2007, Thara Vardhan wrote:

>My data currently reads as follows:
|-----------------------------|---------------------------|
|Output Created               |23-AUG-2007 09:55:05       |
|-----------------------------|---------------------------|
[Transpose]

Incident_category Person_CNI Events_with_LA

Drug detection     xyz               1
Break and enter    xyz               2
Malicious Damage   xyz               1

Number of cases read:  3    Number of cases listed:  3

>I would like to create a data file or an output table as
>
>Personcni  drug detection  Break and enter  Malicious damage
>  xyz            1                2            1

You can't restructure to a data file like that, because
"drug detection", "Break and enter", "Malicious damage"
are not valid SPSS variable names - they contain blanks.

Here's one way to do it, replacing the blanks to make those valid as
variable names. SPSS 15 draft output (WRR:not saved separately):


*  Change blanks in Incident_category to underscores: .
*  (Function "REPLACE" added in SPSS 14)              .

COMPUTE #Length = LENGTH(RTRIM(Incident_category)).
COMPUTE Incident_category =
                   REPLACE(Incident_category,' ','_').
COMPUTE Incident_category =
                   SUBSTR (Incident_category,1,#Length).
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |23-AUG-2007 09:55:06       |
|-----------------------------|---------------------------|
[Transpose]

Incident_category Person_CNI Events_with_LA

Drug_detection     xyz               1
Break_and_enter    xyz               2
Malicious_Damage   xyz               1


Number of cases read:  3    Number of cases listed:  3


CASESTOVARS
    /ID   =Person_CNI
    /INDEX=Incident_category.

Cases to Variables

Notes
|----------------------------|---------------------------|
|Output Created              |23-AUG-2007 09:55:06       |
|----------------------------|---------------------------|
[Transpose]

Generated Variables
|--------------|---------------|---------------|
|Original      |Incident_catego|Result         |
|Variable      |ry             |---------------|
|              |               |Name           |
|--------------|---------------|---------------|
|Events_with_LA|Break_and_enter|Break_and_enter|
|              |---------------|---------------|
|              |Drug_detection |Drug_detection |
|              |---------------|---------------|
|              |Malicious_Damag|Malicious_Damag|
|              |e              |e              |
|--------------|---------------|---------------|

Processing Statistics
|---------------|---|
|Cases In       |3  |
|Cases Out      |1  |
|---------------|---|
|Cases In/Cases |3.0|
|Out            |   |
|---------------|---|
|Variables In   |3  |
|Variables Out  |4  |
|---------------|---|
|Index Values   |3  |
|---------------|---|

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |23-AUG-2007 09:55:06       |
|-----------------------------|---------------------------|
[Transpose]

Person_CNI Break_and_enter Drug_detection Malicious_Damage

  xyz                2              1               1

Number of cases read:  1    Number of cases listed:  1


===================
APPENDIX: Test data
===================
DATA LIST FIXED SKIP=2
    / Incident_category  06-22 (A)
      Person_CNI         27-35 (A)
      Events_with_LA     45-48.
BEGIN DATA
      Incident_category     Person_CNI    Events_with_LA
----|---10----|---20----|---30----|---40----|---50----|
      Drug detection        xyz                 1
      Break and enter       xyz                 2
      Malicious Damage      xyz                 1
END DATA.
DATASET NAME     TestData.

DATASET ACTIVATE TestData  WINDOW=FRONT.
DATASET COPY     Transpose.
DATASET ACTIVATE Transpose WINDOW=FRONT.
LIST.
Reply | Threaded
Open this post in threaded view
|

Re: Testing for system-missing

Richard Ristow
In reply to this post by Jamie Burnett-3
(It's not the greatest idea to start a new question as a 'reply' to a
previous question, so I've renamed your topic.)

At 05:22 AM 8/23/2007, Jamie Burnett wrote:

>I am trying to create a new variable (PS_1A_weight) that will be blank
>if another variable is blank (i.e. sysmis). However I am running into
>trouble with the IF statement recognising sysmis?
>
>IF PS_Class_1A=sysmis  PS_1A_weight=sysmis.

IF  SYSMIS(PS_Class_1A) PS_1A_weight=$sysmis.

Explanation: "=sysmis" is meaningless - system-missing is not a 'value'
as normally understood, but an indication that the value is unknown.
Reply | Threaded
Open this post in threaded view
|

Re: seeking help with file restructure/or as output table

ViAnn Beadle
In reply to this post by Jamie Burnett-3
Sysmis is a function not a constant within transformations--there are
examples in Help.

Please do not hijack somebody else's post to post your question.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Jamie Burnett
Sent: Thursday, August 23, 2007 3:22 AM
To: [hidden email]
Subject: Re: seeking help with file restructure/or as output table

Hi, I am trying to create a new variable (PS_1A_weight) that will be
blank if another variable is blank (i.e. sysmis) and then will take
certain values if another two variables have certain values. However I
am running into trouble with the IF statement recognising sysmis? Can
anyone help?


IF PS_Class_1A=sysmis PS_1A_weight=sysmis.
IF DepSamplex1=0 & PS_Class_1A=1    PS_1A_weight=5.44460377758056.
IF DepSamplex1=0 & PS_Class_1A=2    PS_1A_weight=1.65515855164295.
IF DepSamplex1=0 & PS_Class_1A=3    PS_1A_weight=0.692010920683542.
IF DepSamplex1=0 & PS_Class_1A=4    PS_1A_weight=0.350248923534642.
IF DepSamplex1=0 & PS_Class_1A=5    PS_1A_weight=0.127587064425006.
IF DepSamplex1=1 & PS_Class_1A~=sysmis  PS_1A_weight=1.
Execute.


Thanks

Jamie


============================
This e-mail and all attachments it may contain is confidential and intended
solely for the use of the individual to whom it is addressed. Any views or
opinions presented are solely those of the author and do not necessarily
represent those of Ipsos MORI and its associated companies. If you are not
the intended recipient, be advised that you have received this e-mail in
error and that any use, dissemination, printing, forwarding or copying of
this e-mail is strictly prohibited. Please contact the sender if you have
received this e-mail in error.

Market & Opinion Research International Ltd , Registered in England and
Wales No. 948470 , 79-81 Borough Road , London SE1 1FY, United Kingdom,
Email: [hidden email]
============================
Reply | Threaded
Open this post in threaded view
|

Re: seeking help with file restructure/or as output table

Monica Malone
In reply to this post by thara vardhan-2
On SPSS 14, it looks like you can do this by gong to data on the toobar,
select restructure, then select transpose all data.
Monica Malone

Thara Vardhan wrote:

>Dear List members
>
>I would be grateful if any member could help me with restructuring my data
>file. I have tried the restructure and aggregate function using menu in
>SPSS but I am unable to findout where I am going wrong. I also tried to
>use Ctables function but was only partially successful.
>
>My data currently reads as follows:
>
>Incident category               Person CNI      Events with LA
>
>Drug detection                  xyz                     1
>
>Break and enter                 xyz                     2
>
>Malicious Damage                xyz                     1
>
>I would like to create a data file or an output table as
>
>Personcni     drug detection    Break and enter     Malicious damage
> xyz                     1                              2            1
>
>I would be thankful if any member could help me with this problem.
>
>regards
>Thara Vardhan
>Senior Statistician
>Planning & Results
>Organisation Review and Support
>NSW Police
>Tel: (02) 8835-8526
>
>
>This message and any attachment is confidential and may
>be privileged or otherwise protected from disclosure. If you
>have received it by mistake, please let us know by reply
>and then delete it from your system; you should not copy
>the message or disclose its contents to anyone.
>
>
>