Count percentage of Break Variables

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Count percentage of Break Variables

Deepanshu Bhalla
Hi Team,
 
I want to calculate count percentage of break variables using Aggregate function.
 
Below the syntax which i used. In the syntax i  am calculating count of break variables .Is there any way we can calculate count percentage of break variables?
 
DATASET DECLARE demo003.
AGGREGATE
  /OUTFILE='demo003'
  /BREAK=demo0003 QCL_1
  /Num=N.
 
 
Where demo0003 and QCL_1 are variable names.
 
Note : I know how to use PIN or FIN function but it works only on aggregated variables.
 
 
Thanks in advance!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Count percentage of Break Variables

David Marso

Please define what you mean by "count percentage of break variables" preferably demonstrating with a simple numeric example of inputs and desired output!!
---
deepanshu bhalla wrote
Hi Team,
 
I want to calculate count percentage of break variables using Aggregate function.
 
Below the syntax which i used. In the syntax i  am calculating count of break variables .Is there any way we can calculate count percentage of break variables?
 
DATASET DECLARE demo003.
AGGREGATE
  /OUTFILE='demo003'
  /BREAK=demo0003 QCL_1
  /Num=N.
 
 
Where demo0003 and QCL_1 are variable names.
 
Note : I know how to use PIN or FIN function but it works only on aggregated variables.
 
 
Thanks in advance!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re : Count percentage of Break Variables

Deepanshu Bhalla
Let's say two variables age and gender . I want to compute percentage of females who belong to
 20-24,25-29 ,29-34 and 34-above age categories.

Gender  Age
1           20-24
1           25-29
2           25-29
2           29-34 
1           29-34 
2           34-above
1            20-24 
1            20-24  
2            20-24
1            20-24


I know this can easily be done using Custom Table function in SPSS but i am just curious to know whether this can be done using Aggregate function !


Thanks in advance!

From: David Marso <[hidden email]>
To: [hidden email]
Sent: Tuesday, 21 February 2012 6:51 PM
Subject: Re: Count percentage of Break Variables

Please define what you mean by "count percentage of break variables"
preferably demonstrating with a simple numeric example of inputs and desired
output!!
---

deepanshu bhalla wrote

>
> Hi Team,
> Â
> I want to calculate count percentage of break variables using Aggregate
> function.
> Â
> Below the syntax which i used. In the syntax i  am calculating count of
> break variables .Is there any way we can calculate count percentage of
> break variables?
> Â
> DATASET DECLARE demo003.
> AGGREGATE
>   /OUTFILE='demo003'
>   /BREAK=demo0003 QCL_1
>   /Num=N.
> Â
> Â
> Where demo0003 and QCL_1 are variable names.
> Â
> Note : I know how to use PIN or FIN function but it works only on
> aggregated variables.
> Â
> Â
> Thanks in advance!
>


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Count-percentage-of-Break-Variables-tp5501319p5502167.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
|  
Report Content as Inappropriate
star

Re: Count percentage of Break Variables

David Marso
In reply to this post by David Marso
DATA LIST FREE / Gender (F1)  Age (A10).
BEGIN DATA.
1  20-24
1  25-29
2  25-29
2  29-34
1  29-34
2  34-above
1  20-24
1  20-24  
2  20-24
1  20-24
END DATA.
AGGREGATE OUTFILE * / BREAK Age Gender / N=N.
WEIGHT BY N.
AGGREGATE OUTFILE * / BREAK AGE / P1=PIN(GENDER,1,1)/P2=PIN(GENDER,2,2).
LIST.


AGE           P1    P2

20-24       80.0  20.0
25-29       50.0  50.0
29-34       50.0  50.0
34-above      .0 100.0


Number of cases read:  4    Number of cases listed:  4


David Marso wrote
Please define what you mean by "count percentage of break variables" preferably demonstrating with a simple numeric example of inputs and desired output!!
---
deepanshu bhalla wrote
Hi Team,
 
I want to calculate count percentage of break variables using Aggregate function.
 
Below the syntax which i used. In the syntax i  am calculating count of break variables .Is there any way we can calculate count percentage of break variables?
 
DATASET DECLARE demo003.
AGGREGATE
  /OUTFILE='demo003'
  /BREAK=demo0003 QCL_1
  /Num=N.
 
 
Where demo0003 and QCL_1 are variable names.
 
Note : I know how to use PIN or FIN function but it works only on aggregated variables.
 
 
Thanks in advance!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Re : Count percentage of Break Variables

Bruce Weaver
In reply to this post by Deepanshu Bhalla

* Use OP's data to illustrate.

data list list / Gender(f1) AgeString(a8).
begin data
1           20-24
1           25-29
2           25-29
2           29-34
1           29-34
2           34-above
1            20-24
1            20-24  
2            20-24
1            20-24
end data.

* Numeric variable will be easier to work with, so AUTORECODE.

AUTORECODE VARIABLES=AgeString /INTO AgeCat .
* Confirm recode worked.
crosstabs agestring by agecat.

AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=Gender
  /p1=PLT(AgeCat 2)
  /p2=PIN(AgeCat 2 2)
  /p3=PIN(AgeCat 2 2)
  /p4=PGT(AgeCat 3)
.
sort cases by gender agecat.
list.

* Check result against row percentages from CROSSTABS.

crosstabs gender by agecat / cells = row.

HTH.


deepanshu bhalla wrote
Let's say two variables age and gender . I want to compute percentage of females who belong to

 20-24,25-29 ,29-34 and 34-above age categories.

Gender  Age
1           20-24
1           25-29
2           25-29
2           29-34 
1           29-34 
2           34-above
1            20-24 
1            20-24  
2            20-24
1            20-24


I know this can easily be done using Custom Table function in SPSS but i am just curious to know whether this can be done using Aggregate function !


Thanks in advance!

________________________________
 From: David Marso <[hidden email]>
To: [hidden email] 
Sent: Tuesday, 21 February 2012 6:51 PM
Subject: Re: Count percentage of Break Variables
 
Please define what
 you mean by "count percentage of break variables"
preferably demonstrating with a simple numeric example of inputs and desired
output!!
---

deepanshu bhalla wrote
>
> Hi Team,
> Â
> I want to calculate count percentage of break variables using Aggregate
> function.
> Â
> Below the syntax which i used. In the syntax i  am calculating count of
> break variables .Is there any way we can calculate count percentage of
> break variables?
> Â
> DATASET DECLARE demo003.
> AGGREGATE
>   /OUTFILE='demo003'
>   /BREAK=demo0003 QCL_1
>   /Num=N.
> Â
> Â
> Where demo0003 and QCL_1 are variable names.
> Â
> Note : I know how to use PIN or FIN function but it works only on
> aggregated variables.
> Â
> Â
> Thanks in advance!
>


--
View this message in
 context: http://spssx-discussion.1045642.n5.nabble.com/Count-percentage-of-Break-Variables-tp5501319p5502167.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Count percentage of Break Variables

David Marso
In reply to this post by David Marso
OOPS  I misread the question ;-(
--
DATA LIST FREE / Gender (F1)  Age (A8).
BEGIN DATA.
1  20-24
1  25-29
2  25-29
2  29-34
1  29-34
2  34-above
1  20-24
1  20-24  
2  20-24
1  20-24
END DATA.
RECODE AGE ("20-24"=1)(ELSE=0)    INTO AGE1
      /AGE ("25-29"=1)(ELSE=0)    INTO AGE2
      /AGE ("29-34"=1)(ELSE=0)    INTO AGE3
      /AGE ("34-above"=1)(ELSE=0) INTO AGE4.
AGGREGATE OUTFILE * / BREAK Gender / AGE1 TO AGE4=MEAN(AGE1 TO AGE4).
LIST.

Alternatively you could use the following for the AGGREGATE if you want the form ni/N*100.
AGGREGATE OUTFILE * / BREAK Gender / AGE1 TO AGE4=PIN(AGE1 TO AGE4,1,1).


David Marso wrote
DATA LIST FREE / Gender (F1)  Age (A10).
BEGIN DATA.
1  20-24
1  25-29
2  25-29
2  29-34
1  29-34
2  34-above
1  20-24
1  20-24  
2  20-24
1  20-24
END DATA.
AGGREGATE OUTFILE * / BREAK Age Gender / N=N.
WEIGHT BY N.
AGGREGATE OUTFILE * / BREAK AGE / P1=PIN(GENDER,1,1)/P2=PIN(GENDER,2,2).
LIST.


AGE           P1    P2

20-24       80.0  20.0
25-29       50.0  50.0
29-34       50.0  50.0
34-above      .0 100.0


Number of cases read:  4    Number of cases listed:  4


David Marso wrote
Please define what you mean by "count percentage of break variables" preferably demonstrating with a simple numeric example of inputs and desired output!!
---
deepanshu bhalla wrote
Hi Team,
 
I want to calculate count percentage of break variables using Aggregate function.
 
Below the syntax which i used. In the syntax i  am calculating count of break variables .Is there any way we can calculate count percentage of break variables?
 
DATASET DECLARE demo003.
AGGREGATE
  /OUTFILE='demo003'
  /BREAK=demo0003 QCL_1
  /Num=N.
 
 
Where demo0003 and QCL_1 are variable names.
 
Note : I know how to use PIN or FIN function but it works only on aggregated variables.
 
 
Thanks in advance!
Loading...