aading percentages to an aggregate command

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

aading percentages to an aggregate command

raw
dear all,

may be the solution is very easy but I can't find out how to add needed percentage values in a aggregated file.

I would like to see the frequencies calculated with a simple table in the aggregated file, that is adding the proper command in the aggregate synthax.

data list free/ q1 price.
begin data
1 50
1 20
2 30
2 45
2 45
3 7
1 5
1 65
2 20
end data.

fre q1.


DATASET DECLARE agr_data.
AGGREGATE
  /OUTFILE='agr_data'
  /BREAK=q1
  /price_mean=MEAN(price)
  /price_pgt=PGT(price 0)
  /N_BREAK=N.

I would like to see for the variable price_pgt the values 44, 44, 11
Reply | Threaded
Open this post in threaded view
|

Re: aading percentages to an aggregate command

Andy W
You can do a second AGGREGATE command to get the original total number of items - then calculate the percentage yourself.

************************************.
data list free/ q1 price.
begin data
1 50
1 20
2 30
2 45
2 45
3 7
1 5
1 65
2 20
end data.

fre q1.

DATASET DECLARE agr_data.
AGGREGATE
  /OUTFILE='agr_data'
  /BREAK=q1
  /price_mean=MEAN(price)
  /price_pgt=PGT(price 0)
  /N_BREAK=N.

DATASET ACTIVATE agr_data.
AGGREGATE OUTFILE=* MODE=ADDVARIABLES
  /BREAK
  /TotalN = SUM(N_Break).
COMPUTE price_pgt2 = (N_BREAK/TotalN)*100.
EXECUTE.
************************************.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: aading percentages to an aggregate command

David Marso
Administrator
In reply to this post by raw
Please explain where 44 44 and 11 come from?
I'm not going to bother spending time to figure out what you could explain in your post.
Also why not put all of the grouped values together in the sample data rather than force the reader wander back and forth trying to figure out what you are on about?
raw wrote
dear all,

may be the solution is very easy but I can't find out how to add needed percentage values in a aggregated file.

I would like to see the frequencies calculated with a simple table in the aggregated file, that is adding the proper command in the aggregate synthax.

data list free/ q1 price.
begin data
1 50
1 20
2 30
2 45
2 45
3 7
1 5
1 65
2 20
end data.

fre q1.


DATASET DECLARE agr_data.
AGGREGATE
  /OUTFILE='agr_data'
  /BREAK=q1
  /price_mean=MEAN(price)
  /price_pgt=PGT(price 0)
  /N_BREAK=N.

I would like to see for the variable price_pgt the values 44, 44, 11
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
raw
Reply | Threaded
Open this post in threaded view
|

Re: aading percentages to an aggregate command

raw
Hi David, the 44 44 11 are the frequency % of variable q1.

Just after the "end data" you can see it in my code: fre q1.

Anyway, now it's clear also for people who aren't running my data, I hope
Reply | Threaded
Open this post in threaded view
|

Re: aading percentages to an aggregate command

David Marso
Administrator
raw wrote
Hi David, the 44 44 11 are the frequency % of variable q1.

Just after the "end data" you can see it in my code: fre q1.

Anyway, now it's clear also for people who aren't running my data, I hope
data list free/ q1 price.
begin data
1 50    1 20    1  5    1 65
2 30    2 45    2 45    2 20
3  7
end data.

SORT CASES BY q1.
AGGREGATE OUTFILE * MODE ADDVARIABLES / BREAK q1 /Count=N / Mean_Price=MEAN(Price).
AGGREGATE OUTFILE * MODE ADDVARIABLES /BREAK /Total_N=N.
COMPUTE Pct=Count/Total_N * 100.
LIST.

      q1    price   Count Mean_Price Total_N      Pct
 
    1.00    50.00       4     35.00        9    44.44
    1.00    20.00       4     35.00        9    44.44
    1.00     5.00       4     35.00        9    44.44
    1.00    65.00       4     35.00        9    44.44
    2.00    30.00       4     35.00        9    44.44
    2.00    45.00       4     35.00        9    44.44
    2.00    45.00       4     35.00        9    44.44
    2.00    20.00       4     35.00        9    44.44
    3.00     7.00       1      7.00        9    11.11
 
 
Number of cases read:  9    Number of cases listed:  9
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"