Date: Tue, 21 Sep 2010 12:32:22 -0700
Reply-To: Peter Link <plink@vapop.ucsd.edu>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Peter Link <plink@vapop.ucsd.edu>
Subject: Re: Fw: counting frequencies of 30 columns of children
who are a certain age range AND going
to school.
In-Reply-To: <302579.13014.qm@web56904.mail.re3.yahoo.com>
Content-Type: multipart/alternative;
Deepa -
B5_Age$11 has a space after the underscore and before Age, in your syntax
below. This causes the error.
Peter Link
VA San Diego Healthcare System
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of
Deepa Lakshmi Shanadi
Sent: Tuesday, September 21, 2010 12:04 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: [SPSSX-L] Fw: counting frequencies of 30 columns of children who
are a certain age range AND going to school.
Why am I getting this silly error message for the following syntax???
>Error # 4285 in column 2. Text: B5_
>Incorrect variable name: either the name is more than 64 characters, or
it is
>not defined by a previous command.
>This command not executed.
EXECUTE.
WOULD THIS WORK to calculate those that are aged 7to15 and going to school
in my 30 columns from 2 sets of varibles? Sorry, I am having a hard time
following the shortened syntax.
COMPUTE age7to15andschool = ((B5_AGE$01>6 and B5_AGE$01 < 16) and
(B8_CURATSCH$01 = 1)) or
(B5_AGE$02>6 and B5_AGE$02 <16 and B8_CURATSCH$02 = 1 )
or (B5_AGE$03>6 and B5_AGE$03 <16 and B8_CURATSCH$03 = 1) or
(B5_AGE$04>6 and B5_AGE$04 <16 and B8_CURATSCH$04 = 1 ) or
(B5_AGE$05>6 and B5_AGE$05 <16 and B8_CURATSCH$05 = 1) or
(B5_AGE$06>6 and B5_AGE$06 <16 and B8_CURATSCH$06 = 1) or
(B5_AGE$07>6 and B5_AGE$07 <16 and B8_CURATSCH$07 = 1) or
(B5_AGE$08>6 and B5_AGE$08 <16 and B8_CURATSCH$08 = 1)
or (B5_AGE$09>6 and B5_AGE$09 <16 and B8_CURATSCH$09 = 1) or
(B5_AGE$10>6 and B5_AGE$10<16 and B8_CURATSCH$10 = 1) or
(B5_ AGE$11>6 and B5_AGE$11 <16 and B8_CURATSCH$11 = 1) or
(B5_AGE$12>6 and B5_AGE$12 <16 and B8_CURATSCH$12 = 1)
or (B5_AGE$13>6 and B5_AGE$13 <16 and B8_CURATSCH$13 = 1) or
(B5_AGE$14>6 and B5_AGE$14<16 and B8_CURATSCH$14 = 1) or
(B5_AGE$15>6 and B5_AGE$15 <16 and B8_CURATSCH$15 = 1)
or (B5_AGE$16>6 and B5_AGE$16 <16 and B8_CURATSCH$16 = 1) or
(B5_AGE$17>6 and B5_AGE$17 <16 and B8_CURATSCH$17 = 1) or
(B5_AGE$18>6 and B5_AGE$18 <16 B8_CURATSCH$18 = 1) or
(B5_AGE$19>6 and B5_AGE$19 <16 and B8_CURATSCH$19=1)
or (B5_AGE$20>6 and B5_AGE$20<16 and B8_CURATSCH$20 = 1) or
(B5_AGE$21>6 and B5_AGE$21<16 and B8_CURATSCH$21 = 1) or
(B5_AGE$22>6 and B5_AGE$22<16 and B8_CURATSCH$22 = 1) or
(B5_AGE$23>6 and B5_AGE$23<16 and B8_CURATSCH$23 = 1)
or (B5_AGE$24<6 and B5_AGE$24<16 and B8_CURATSCH$24 = 1) or
(B5_AGE$25>6 and B5_AGE$25<16 and B8_CURATSCH$25 = 1) or
(B5_AGE$26>6 and B5_AGE$26<16 and B8_CURATSCH$26 = 1) or
(B5_AGE$27>2 and B5_AGE$27<16 and B8_CURATSCH$27 = 1) or
(B5_AGE$28>6 and B5_AGE$28<16 and B8_CURATSCH$28 = 1) or
(B5_AGE$29>6 and B5_AGE$29<16 and B8_CURATSCH$29=1) or
(B5_AGE$30>6 and B5_AGE$30<16 and B8_CURATSCH$30 = 1).
EXECUTE.
But I get this message:
>Error # 4285 in column 2. Text: B5_
>Incorrect variable name: either the name is more than 64 characters, or
it is
>not defined by a previous command.
>This command not executed.
EXECUTE.
----------------------------------------------------------------------------
--
From: John F Hall <johnfhall@orange.fr>
To: Deepa Lakshmi Shanadi <deepab121@yahoo.com>; SPSSX-L@LISTSERV.UGA.EDU
Sent: Tue, September 21, 2010 1:34:49 PM
Subject: Re: counting frequencies of 30 columns of children who are a
certain age range AND going to school.
Deepa,
IF is a very expensive way to do this, as SPSS makes a pass through the
data for each IF. Do you really need v1 to v30?
you can do:
count age3to18 = b5_age$01 to b5_age$30 (3 thru 18)
/age6to15 = b5_age$01 to b5_age$30 (7 thru 15)
/atschool = B8_CURATSCH$01 to B8_CURATSCH$30 (1) .
freq age3to18 to atschool .
If you need the columns paired (untested) something like:
do repeat
x = b5_age$01 to b5_age$30
/y = b5_age$01 to b5_age$30
/z = B8_CURATSCH$01 to B8_CURATSCH$30
/a = v1 to v30
/b = w1 to w30 .
if ((x ge3 and le 18) and (z eq 1)) a = 1 .
if ((y ge 7 and le 15) and (z eq 1)) b = 1 .
end repeat .
count atschool3to18 = v1 to v30 (1)
/atschool7to15 = w1 to w30 (1) .
freq atschool3to18 atschool7to15 .
John Hall
johnfhall@orange.fr
http://surveyresearch.weebly.com
----- Original Message -----
From: Deepa Lakshmi Shanadi
To: SPSSX-L@LISTSERV.UGA.EDU
Sent: Tuesday, September 21, 2010 5:54 PM
Subject: counting frequencies of 30 columns of children who are a
certain age range AND going to school.
Dear all,
I sent an email on needing to count how many children there are in 30
columns that are between the ages of 3 to 18 AND are going to school. Thanks
for your response. I picked the following and it seemed to work.
This is what I went with. IT worked for 3to18 and going to school, but
then I adapted it to age range 7to15 AND going to school, but for some
reason it is only picking up the part on those that are going to school, so
if someone is NOT 7to15 years old, but are going to school, it is counting
that. Any insight on why? Also how would you shorten this syntax?
FILTER OFF.
USE ALL.
EXECUTE.
If ((b5_age$01 > 6 | b5_age$01 < 16) & (B8_CURATSCH$01 = 1)) v1 = 1.
If ((b5_age$02 > 6 | b5_age$02 <16) & (B8_CURATSCH$02 = 1)) v2 = 1.
If ((b5_age$03 > 6 | b5_age$03 < 16) & (B8_CURATSCH$03 = 1)) v3 = 1.
If ((b5_age$04 > 6 | b5_age$04 < 16) & (B8_CURATSCH$04 = 1)) v4 = 1.
If ((b5_age$05 > 6 | b5_age$05 < 16) & (B8_CURATSCH$05 = 1)) v5 = 1.
If ((b5_age$06 > 6 | b5_age$06 < 16) & (B8_CURATSCH$06 = 1)) v6 = 1.
If ((b5_age$07 > 6 | b5_age$07 < 16) & (B8_CURATSCH$07 = 1)) v7 = 1.
If ((b5_age$08 > 6 | b5_age$08 < 16) & (B8_CURATSCH$08 = 1)) v8 = 1.
If ((b5_age$09 > 6 | b5_age$09 < 16) & (B8_CURATSCH$09 = 1)) v9 = 1.
If ((b5_age$10 > 6 | b5_age$10 < 16) & (B8_CURATSCH$10 = 1)) v10 = 1.
If ((b5_age$11 > 6 | b5_age$11 < 16) & (B8_CURATSCH$11 = 1)) v11 = 1.
If ((b5_age$12 > 6 | b5_age$12 < 16) & (B8_CURATSCH$12 = 1)) v12 = 1.
If ((b5_age$13 > 6 | b5_age$13 < 16) & (B8_CURATSCH$13= 1)) v13 = 1.
If ((b5_age$14> 6 | b5_age$14 < 16) & (B8_CURATSCH$14= 1)) v14 = 1.
If ((b5_age$15 > 6 | b5_age$15 < 16) & (B8_CURATSCH$15= 1)) v15 = 1.
If ((b5_age$16 > 6 | b5_age$16 < 16) & (B8_CURATSCH$16= 1)) v16 = 1.
If ((b5_age$17 > 6 | b5_age$17 < 16) & (B8_CURATSCH$17= 1)) v17 = 1.
If ((b5_age$18> 6 | b5_age$18 < 16) & (B8_CURATSCH$18= 1)) v18 = 1.
If ((b5_age$19> 6 | b5_age$19 < 16) & (B8_CURATSCH$19= 1)) v19 = 1.
If ((b5_age$20 > 6 | b5_age$20 < 16) & (B8_CURATSCH$20= 1)) v20 = 1.
If ((b5_age$21 > 6 | b5_age$21 < 16) & (B8_CURATSCH$21= 1)) v21 = 1.
If ((b5_age$22 > 6 | b5_age$22 < 16) & (B8_CURATSCH$22= 1)) v22= 1.
If ((b5_age$23> 6 | b5_age$23 < 16) & (B8_CURATSCH$23= 1)) v23 = 1.
If ((b5_age$24> 6 | b5_age$24 < 16) & (B8_CURATSCH$24= 1)) v24 = 1.
If ((b5_age$25> 6 | b5_age$25 < 16) & (B8_CURATSCH$25= 1)) v25= 1.
If ((b5_age$26> 6 | b5_age$26 < 16) & (B8_CURATSCH$26= 1)) v26 = 1.
If ((b5_age$27> 6 | b5_age$27 < 16) & (B8_CURATSCH$27= 1)) v27 = 1.
If ((b5_age$28> 6 | b5_age$28 < 16) & (B8_CURATSCH$28= 1)) v28 = 1.
If ((b5_age$29> 6 | b5_age$29 < 16) & (B8_CURATSCH$29= 1)) v29 = 1.
If ((b5_age$30> 6 | b5_age$30 < 16) & (B8_CURATSCH$30= 1)) v30 = 1.
COUNT age7to15andschoolfrequency = v1 to v30 (1).
EXECUTE.
FREQUENCIES VARIABLES=age7to15andschoolfrequency
/ORDER=ANALYSIS.
Would this work?
[text/html]