Dear experts, Do you have any snippets how percentiles, quartiles are obtained? Is there a know command (syntax) to execute them, especially in aggregate command? Feeling shy querying a naïve question. Any help appreciated. Regards, samuel |
Various procedures, including Frequencies, can produce quartiles/percentiles. Aggregate does not do percentiles, but there is an example in the help system that shows how to use OMS to obtain aggregated percentiles. Using the Search tab in the help system, type "percentiles aggregate".
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Samuel Solomon Sent: Monday, March 19, 2007 10:12 AM To: [hidden email] Subject: percentiles,quartiles???? Dear experts, Do you have any snippets how percentiles, quartiles are obtained? Is there a know command (syntax) to execute them, especially in aggregate command? Feeling shy querying a naïve question. Any help appreciated. Regards, samuel |
In reply to this post by Samuel Solomon
I do not understand the reference to.
However, the RANK procedure was designed specifically for this. It produces many different kinds of rank scores for cases. In the syntax window, type RANK, highlight it, and then click the syntax button. If RANK is not what you want, please restate your question in more detail. Perhaps post a small data set with variables "have" and "want". If rather than percentile scores you wish some kind of ntile *cuts.*, see the FREQUENCIES procedure. Art Kendall Social Research Consultants Samuel Solomon wrote: > > > Dear experts, > > > > Do you have any snippets how percentiles, quartiles are obtained? Is there a know command (syntax) to execute them, especially in aggregate command? > > Feeling shy querying a naïve question. > > Any help appreciated. > > Regards, > > samuel > > > > > > >
Art Kendall
Social Research Consultants |
that should have started out:
I do not understand the reference to AGGREGATE. Art Art Kendall wrote: > I do not understand the reference to. > > However, the RANK procedure was designed specifically for this. It > produces many different kinds of rank scores for cases. > In the syntax window, type RANK, highlight it, and then click the syntax > button. > > If RANK is not what you want, please restate your question in more > detail. > Perhaps post a small data set with variables "have" and "want". > > If rather than percentile scores you wish some kind of ntile *cuts.*, > see the FREQUENCIES procedure. > > > Art Kendall > Social Research Consultants > > Samuel Solomon wrote: >> >> >> Dear experts, >> >> >> >> Do you have any snippets how percentiles, quartiles are obtained? Is >> there a know command (syntax) to execute them, especially in >> aggregate command? >> >> Feeling shy querying a naïve question. >> >> Any help appreciated. >> >> Regards, >> >> samuel >> >> >> >> >> >> >> > > |
In reply to this post by Samuel Solomon
hi Hector,
I appreciate your effort but I must you use Aggregate command because I desperately want to compute the percentiles or quartiles of the figures which belong to same group and also I think that is the only command which brings figure to their corresponding group on account of the Break subcommand.. or perhaps ,can you think of any other command alternative to aggregate command which has the advantage over the latter. I hope I am not asking you to re-engineer the software. From: [hidden email] [mailto:[hidden email]] Sent: Mon 3/19/2007 6:29 PM To: Samuel Solomon Subject: Re: percentiles,quartiles???? You can find out which is the value below which a certain percentage of cases is found, i.e. a percentile, as a by-product of the FREQUENCIES command (among other possibilities). Look at FREQUENCIES /STAT PERCENTILES in the syntax reference for more details. Look also for the NTILES keyford for any number of equally spaced percentiles (NTILES 5 would produce quintile values, with 20% of cases in each quintile; NTILES 20 would produce 20 percentile groups with 5% of cases each). If you want percentiles not on the entire sample but within each of several subgroups defined by some categorical variable, you may use EXAMINE, which can accept control variables and produce percentile values. You can also use SPLIT FILE and proceed with FREQUENCIES. In AGGREGATE there are aggregation functions based on the value/s encompassing a certain proportion of cases, like PIN and POUT. They will characterize each aggregated or resulting group by the proportion of elementary cases above or below a certain value, or within two given values. But that is not exactly what you want. I do not remember right now whether you can compute the value of a given quantile within each group in AGGREGATE. I tend to think you cannot, but I might be wrong. Hector ----- Mensaje original ----- De: Samuel Solomon <[hidden email]> Fecha: Lunes, Marzo 19, 2007 4:12 pm Asunto: percentiles,quartiles???? > > > Dear experts, > > > > Do you have any snippets how percentiles, quartiles are obtained? > Is there a know command (syntax) to execute them, especially in > aggregate command? > > Feeling shy querying a naïve question. > > Any help appreciated. > > Regards, > > samuel > > > > > |
In reply to this post by Samuel Solomon
As I suggested before, you can use FREQUENCIES combined with SPLIT FILE, which produce separate frequency tables for each group. The only drawback of this approach is that you get one table per group, and perhaps your groups are many.
If you just want to know the value of the percentiles or quartiles, FREQUENCY would do. If you want instead the value of the percentiles/quantiles for each group as variables in a new aggregated data set, like the files produced by AGGREGATE, I do not know how to produce them at the moment (I am travelling now, without my SPSS, and would have to look at it in detail when I get home). The only function I can think of in Aggregate is the function giving you the proportion of cases below a certain value. But this is the reverse of what you want: with that function, you must specify the value to get the percentage, whereas what you want is to specify the percentage and get the value (e.g. you want to specify 20% to get the value of the first quintile, 40% for the value of the second quintile, and so on). If no other possibility exists, and nobody provides you with a macro to automate the job, you should use FREQUENCIES and copy the percentile values from every FREQUENCY percentile or ntile table into an Excel spreadsheet or a new SPSS data set. Sorry for not being more helpful. I am copying this to the mailing list just in case somebody gets the idea and provides something you can use. Hector ----- Mensaje original ----- De: Samuel Solomon <[hidden email]> Fecha: Martes, Marzo 20, 2007 9:31 am Asunto: Re: percentiles,quartiles???? > hi Hector, > I appreciate your effort but I must you use Aggregate command > because I desperately want to compute the percentiles or quartiles > of the figures which belong to same group and also I think that is > the only command which brings figure to their corresponding group > on account of the Break subcommand.. or perhaps ,can you think of > any other command alternative to aggregate command which has the > advantage over the latter. I hope I am not asking you to re- > engineer the software. > > > From: [hidden email] [[hidden email]] > Sent: Mon 3/19/2007 6:29 PM > To: Samuel Solomon > Subject: Re: percentiles,quartiles???? > > > > You can find out which is the value below which a certain > percentage of cases is found, i.e. a percentile, as a by-product > of the FREQUENCIES command (among other possibilities). Look at > FREQUENCIES /STAT PERCENTILES in the syntax reference for more > details. Look also for the NTILES keyford for any number of > equally spaced percentiles (NTILES 5 would produce quintile > values, with 20% of cases in each quintile; NTILES 20 would > produce 20 percentile groups with 5% of cases each). > > If you want percentiles not on the entire sample but within each > of several subgroups defined by some categorical variable, you may > use EXAMINE, which can accept control variables and produce > percentile values. You can also use SPLIT FILE and proceed with > FREQUENCIES. > In AGGREGATE there are aggregation functions based on the value/s > encompassing a certain proportion of cases, like PIN and POUT. > They will characterize each aggregated or resulting group by the > proportion of elementary cases above or below a certain value, or > within two given values. But that is not exactly what you want. I > do not remember right now whether you can compute the value of a > given quantile within each group in AGGREGATE. I tend to think you > cannot, but I might be wrong. > > Hector > > ----- Mensaje original ----- > De: Samuel Solomon <[hidden email]> > Fecha: Lunes, Marzo 19, 2007 4:12 pm > Asunto: percentiles,quartiles???? > > > > > > > Dear experts, > > > > > > > > Do you have any snippets how percentiles, quartiles are obtained? > > Is there a know command (syntax) to execute them, especially in > > aggregate command? > > > > Feeling shy querying a naïve question. > > > > Any help appreciated. > > > > Regards, > > > > samuel > > > > > > > > > > > |
In reply to this post by Samuel Solomon
This is example syntax that produces quartiles, percentiles, and
z_scores within groups. GET FILE='C:\Program Files\SPSS15\Cars.sav'. RANK VARIABLES = mpg accel horse BY origin cylinder / ntiles(4) into quart_mpg quart_accel quart_horse / percent into pct_mpg pct_accel pct_horse / normal into z_mpg z_accel z_horse. Save all your current work, then open a new instance of SPSS. Make sure that you put warnings, etc. into the output file. <edit> <options> <viewer>. Cut-and-paste then run the syntax. Does this do what you want? If not please restate your question in more detail. Perhaps post a small data set with variables "have" and "want". Hope this helps. Art Social Research Consultants Samuel Solomon wrote: > hi Hector, > I appreciate your effort but I must you use Aggregate command because I desperately want to compute the percentiles or quartiles of the figures which belong to same group and also I think that is the only command which brings figure to their corresponding group on account of the Break subcommand.. or perhaps ,can you think of any other command alternative to aggregate command which has the advantage over the latter. I hope I am not asking you to re-engineer the software. > > > From: [hidden email] [mailto:[hidden email]] > Sent: Mon 3/19/2007 6:29 PM > To: Samuel Solomon > Subject: Re: percentiles,quartiles???? > > > > You can find out which is the value below which a certain percentage of cases is found, i.e. a percentile, as a by-product of the FREQUENCIES command (among other possibilities). Look at FREQUENCIES /STAT PERCENTILES in the syntax reference for more details. Look also for the NTILES keyford for any number of equally spaced percentiles (NTILES 5 would produce quintile values, with 20% of cases in each quintile; NTILES 20 would produce 20 percentile groups with 5% of cases each). > > If you want percentiles not on the entire sample but within each of several subgroups defined by some categorical variable, you may use EXAMINE, which can accept control variables and produce percentile values. You can also use SPLIT FILE and proceed with FREQUENCIES. > > In AGGREGATE there are aggregation functions based on the value/s encompassing a certain proportion of cases, like PIN and POUT. They will characterize each aggregated or resulting group by the proportion of elementary cases above or below a certain value, or within two given values. But that is not exactly what you want. I do not remember right now whether you can compute the value of a given quantile within each group in AGGREGATE. I tend to think you cannot, but I might be wrong. > > Hector > > ----- Mensaje original ----- > De: Samuel Solomon <[hidden email]> > Fecha: Lunes, Marzo 19, 2007 4:12 pm > Asunto: percentiles,quartiles???? > > >> Dear experts, >> >> >> >> Do you have any snippets how percentiles, quartiles are obtained? >> Is there a know command (syntax) to execute them, especially in >> aggregate command? >> >> Feeling shy querying a naïve question. >> >> Any help appreciated. >> >> Regards, >> >> samuel >> >> >> >> >> >> > > > |
As your example demonstrates, Rank can produce ranks based on percentiles within categories of one or more grouping variables -- but all it produces are the sequential ranks (1,2,3...). It does not provide any information on the cutpoint values that deefine the ranks.
Using Split File with Frequencies will produce a table that provides the cutpoint values associated with each percentile for each group, as in: sort cases by groupvar. split file layered by groupvar. frequencies variables=scalevar /format=notable /percentiles=25 50 75. Taking this one step further, you can use OMS to include those group percentile values in the data file in a fashion similar to what Aggregate does for various summary functions. This is described in some detail in the help system (use the Help Search tab to search for "aggregate percentiles"), but here's an example without the detailed explanation: ******create some sample data******. dataset close all. output close name=all. new file. set seed 123456789. input program. loop #i=1 to 100. compute id=#i. compute groupvar=trunc(rv.uniform(1,5)). compute scalevar=rv.normal(50,10). end case. end loop. end file. end input program. *****start real job******. dataset name original. dataset declare percentiles. sort cases by groupvar. split file layered by groupvar. preserve. set tvars names tnumbers values. oms /select tables /if subtypes=['Statistics'] /destination format=sav outfile=percentiles /columns sequence=[L1 R2]. frequencies variables=scalevar /format=notable /percentiles=25 50 75. omsend. restore. match files file=original /table=percentiles /rename (var1=groupvar) /by groupvar /drop command_ to scalevar_missing. execute. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Art Kendall Sent: Tuesday, March 20, 2007 7:04 AM To: [hidden email] Subject: Re: percentiles,quartiles???? This is example syntax that produces quartiles, percentiles, and z_scores within groups. GET FILE='C:\Program Files\SPSS15\Cars.sav'. RANK VARIABLES = mpg accel horse BY origin cylinder / ntiles(4) into quart_mpg quart_accel quart_horse / percent into pct_mpg pct_accel pct_horse / normal into z_mpg z_accel z_horse. Save all your current work, then open a new instance of SPSS. Make sure that you put warnings, etc. into the output file. <edit> <options> <viewer>. Cut-and-paste then run the syntax. Does this do what you want? If not please restate your question in more detail. Perhaps post a small data set with variables "have" and "want". Hope this helps. Art Social Research Consultants Samuel Solomon wrote: > hi Hector, > I appreciate your effort but I must you use Aggregate command because I desperately want to compute the percentiles or quartiles of the figures which belong to same group and also I think that is the only command which brings figure to their corresponding group on account of the Break subcommand.. or perhaps ,can you think of any other command alternative to aggregate command which has the advantage over the latter. I hope I am not asking you to re-engineer the software. > > > From: [hidden email] [mailto:[hidden email]] > Sent: Mon 3/19/2007 6:29 PM > To: Samuel Solomon > Subject: Re: percentiles,quartiles???? > > > > You can find out which is the value below which a certain percentage of cases is found, i.e. a percentile, as a by-product of the FREQUENCIES command (among other possibilities). Look at FREQUENCIES /STAT PERCENTILES in the syntax reference for more details. Look also for the NTILES keyford for any number of equally spaced percentiles (NTILES 5 would produce quintile values, with 20% of cases in each quintile; NTILES 20 would produce 20 percentile groups with 5% of cases each). > > If you want percentiles not on the entire sample but within each of several subgroups defined by some categorical variable, you may use EXAMINE, which can accept control variables and produce percentile values. You can also use SPLIT FILE and proceed with FREQUENCIES. > > In AGGREGATE there are aggregation functions based on the value/s encompassing a certain proportion of cases, like PIN and POUT. They will characterize each aggregated or resulting group by the proportion of elementary cases above or below a certain value, or within two given values. But that is not exactly what you want. I do not remember right now whether you can compute the value of a given quantile within each group in AGGREGATE. I tend to think you cannot, but I might be wrong. > > Hector > > ----- Mensaje original ----- > De: Samuel Solomon <[hidden email]> > Fecha: Lunes, Marzo 19, 2007 4:12 pm > Asunto: percentiles,quartiles???? > > >> Dear experts, >> >> >> >> Do you have any snippets how percentiles, quartiles are obtained? >> Is there a know command (syntax) to execute them, especially in >> aggregate command? >> >> Feeling shy querying a naïve question. >> >> Any help appreciated. >> >> Regards, >> >> samuel >> >> >> >> >> >> > > > |
In reply to this post by Samuel Solomon
Try the example syntax below the sig block.
Save all your current work, then open a new instance of SPSS. Make sure that you put warnings, etc. into the output file. <edit> <options> <viewer>. Cut-and-paste then run the syntax. Does this do what you want? If not please restate your question in more detail. Hope this helps. Art [hidden email] Social Research Consultants new file. set seed 20070321. input program. loop impor=1 to 2. loop com_no = 1 to 5. loop id = 1 to 50. leave impor com_no. compute item_price=rnd(rv.uniform(20,80)). end case. end loop. end loop. end loop. end file. end input program. execute. numeric groupvar (n2). compute groupvar = (impor *10) + com_no. rank variables = item_price by groupvar /ntiles (4) into quartile_price /percent into pctl_price. crosstabs tables = groupvar by quartile_price. if quartile_price eq 1 q1_price = item_price. if quartile_price le 3 q3_price = item_price. if pctl_price le 5 p5_price = item_price. if pctl_price le 25 p25_price = item_price. dataset declare aggdata. aggregate outfile=aggdata /break = impor com_no /min_item_price = min(item_price) /max_item_price = max(item_price) /Q1_item_price_cut = max(q1_price) /Q3_item_price_cut = max(q3_price) /P5_item_price_cut = max(p5_price) /P25_item_price_cut = max(p25_price). dataset activate aggdata. list. Samuel Solomon wrote: > > hello Art, > > > > Oh at first your syntax looks promising. Would that syntax able to > deliver me seperate quartiles(Q1,Q2...) and percetiles( p5,p25...and > p95) of figures belonging to the same group. can you make it more > flexible. let me rephrase what i desire. > > > > my data looks like this, > > > > year month impor county com_no quan value sitc > cpa item_price > > 2003 12 2 YE 01042000 25 2125 00122 > 021100 85.00 > > 2003 12 2 YE 01042000 73 1980 00122 > 021100 27.12 > > 2003 12 2 YE 01042000 21 1785 00122 > 021100 85.00 > > 2003 12 2 YE 01042000 20 1700 00122 > 021100 85.00 > > 2003 12 2 YE 01042000 19 1615 00122 > 021100 85.00 > > 2003 12 2 YE 01042000 12 1020 00122 > 021100 85.00 > > 2003 12 2 YE 01042000 5 425 00122 > 021100 85.00 > > 2003 12 2 YE 01042000 2 170 00122 > 021100 85.00 > > 2004 11 1 SA 01051100 13000 176100 00141 > 021200 13.55 > > 2004 12 1 EG 01051100 13000 308200 00141 > 021200 23.71 > > 2004 11 1 SA 01051100 13000 176100 00141 > 021200 13.55 > > 2004 11 1 SA 01051100 13000 176100 00141 > 021200 13.55 > > 2004 11 1 DE 01051100 66959 941850 00141 > 021200 14.07 > > 2004 04 1 EG 01051100 5000 98265 00141 > 021200 19.65 > > 2004 08 1 SA 01051100 13000 177825 00141 > 021200 13.68 > > 2004 08 1 SA 01051100 13000 176100 00141 > 021200 13.55 > > 2003 12 1 EG 01051100 10400 217185 00141 > 021200 20.88 > > > > Having this data in mind, I wish to aggregate the above sample data > and create new variables, through the aggregate function subcommands, > in the aggregated data file. > > My break variables are (/break =impor com_no). I want generate new > variables(the aggregated mean, median, Q1 , Q3, P5, P25, max and min > of 'item_price' variable) in the aggregated data outfile. > > > > I tried it with this syntax but to no avail. > > > > aggregate outfile ='W:\User_xx\User_samuel\SPSS\Index\WK99\med_1b.sav' > > /break =imp_exp com_numb > > /med_pric = median(item_pri) /n=NU(item_pri) /p5= ptile(item_pri). > > > > It is imperative that the new variables min_item_price, max_item_price > ,Q1_item_price, Q3_item_price,P5_item_price, P25_price, > max_item_price, min_item_price are created. Creating Q1_item_price, > Q3_item_price,P5_item_price, P25_price are still a nightmare to me. So > have now got the picture, I couldn't make it more elucidated than this. > > > > Altimately my out put data file should look like this, > > > > Impor com_no min_item_price max_item_price Q1_item_price > Q3_item_price P5_item_price P25_price max_item_price > min_item_price > > . . . > > . > > . . > > . > > . > > . > > . > > > > > > Thanks, > > Samuel > > > > ------------------------------------------------------------------------ > > *From:* Art Kendall [mailto:[hidden email]] > *Sent:* Tuesday, March 20, 2007 3:04 PM > *To:* Samuel Solomon > *Cc:* [hidden email] > *Subject:* Re: percentiles,quartiles???? > > > > This is example syntax that produces quartiles, percentiles, and z_scores within groups. > > > > > > GET > > FILE='C:\Program Files\SPSS15\Cars.sav'. > > RANK VARIABLES = mpg accel horse BY origin cylinder > > / ntiles(4) into quart_mpg quart_accel quart_horse > > / percent into pct_mpg pct_accel pct_horse > > / normal into z_mpg z_accel z_horse. > > > > > > Save all your current work, then open a new instance of SPSS. Make sure that you put warnings, etc. into the output file. <edit> <options> <viewer>. Cut-and-paste then run the syntax. > > Does this do what you want? If not please restate your question in more detail. > > Perhaps post a small data set with variables "have" and "want". > > > > Hope this helps. > > > > Art > > > > Social Research Consultants > > > > > > > > > > > > > |
Shalom
Here is another way of producing percentiles . this example will not be a precise as using the built in procedures but is more flexible and can be improve . title ' create percentiles ' . new file. set seed 20070321. input program. loop good=1 to 2. loop month= 1 to 5. loop id = 1 to 50. leave good month id. compute price=rnd(rv.uniform(20,80)). end case. end loop. end loop. end loop. end file. end input program. execute. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=good month /nprice= n(price). sort cases by good month price. add files file=* / by good month / first=first. leave runprice . if first eq 1 runprice =0 . compute runprice =sum( runprice ,1) . if ( runprice / nprice)* 100 ge 25 price25=1 . if ( runprice / nprice)* 100 ge 75 price75=1 . execute . recode price25 price75(sysmis=-1) . if (lag(price25,1) eq -1) and (price25 eq 1) price25=price . if (lag(price75,1) eq -1) and (price75 eq 1) price75=price . execute . recode price25 price75(-1 1=sysmis)(2=1) . AGGREGATE /OUTFILE=* /BREAK=good month /price25 price75= max(price25 price75). dataset name percn . Hillel Vardi Art Kendall wrote: > Try the example syntax below the sig block. > > Save all your current work, then open a new instance of SPSS. Make sure > that you put warnings, etc. into the output file. <edit> <options> > <viewer>. Cut-and-paste then run the syntax. > Does this do what you want? If not please restate your question in more > detail. > > Hope this helps. > > > > Art > [hidden email] > Social Research Consultants > > > > new file. > set seed 20070321. > input program. > loop impor=1 to 2. > loop com_no = 1 to 5. > loop id = 1 to 50. > leave impor com_no. > compute item_price=rnd(rv.uniform(20,80)). > end case. > end loop. > end loop. > end loop. > end file. > end input program. > execute. > numeric groupvar (n2). > compute groupvar = (impor *10) + com_no. > rank variables = item_price by groupvar /ntiles (4) into quartile_price > /percent into pctl_price. > crosstabs tables = groupvar by quartile_price. > if quartile_price eq 1 q1_price = item_price. > if quartile_price le 3 q3_price = item_price. > if pctl_price le 5 p5_price = item_price. > if pctl_price le 25 p25_price = item_price. > dataset declare aggdata. > aggregate outfile=aggdata > /break = impor com_no > /min_item_price = min(item_price) > /max_item_price = max(item_price) > /Q1_item_price_cut = max(q1_price) > /Q3_item_price_cut = max(q3_price) > /P5_item_price_cut = max(p5_price) > /P25_item_price_cut = max(p25_price). > dataset activate aggdata. > list. > > > > > > > > > Samuel Solomon wrote: >> >> hello Art, >> >> >> >> Oh at first your syntax looks promising. Would that syntax able to >> deliver me seperate quartiles(Q1,Q2...) and percetiles( p5,p25...and >> p95) of figures belonging to the same group. can you make it more >> flexible. let me rephrase what i desire. >> >> >> >> my data looks like this, >> >> >> >> year month impor county com_no quan value sitc >> cpa item_price >> >> 2003 12 2 YE 01042000 25 2125 00122 >> 021100 85.00 >> >> 2003 12 2 YE 01042000 73 1980 00122 >> 021100 27.12 >> >> 2003 12 2 YE 01042000 21 1785 00122 >> 021100 85.00 >> >> 2003 12 2 YE 01042000 20 1700 00122 >> 021100 85.00 >> >> 2003 12 2 YE 01042000 19 1615 00122 >> 021100 85.00 >> >> 2003 12 2 YE 01042000 12 1020 00122 >> 021100 85.00 >> >> 2003 12 2 YE 01042000 5 425 00122 >> 021100 85.00 >> >> 2003 12 2 YE 01042000 2 170 00122 >> 021100 85.00 >> >> 2004 11 1 SA 01051100 13000 176100 00141 >> 021200 13.55 >> >> 2004 12 1 EG 01051100 13000 308200 00141 >> 021200 23.71 >> >> 2004 11 1 SA 01051100 13000 176100 00141 >> 021200 13.55 >> >> 2004 11 1 SA 01051100 13000 176100 00141 >> 021200 13.55 >> >> 2004 11 1 DE 01051100 66959 941850 00141 >> 021200 14.07 >> >> 2004 04 1 EG 01051100 5000 98265 00141 >> 021200 19.65 >> >> 2004 08 1 SA 01051100 13000 177825 00141 >> 021200 13.68 >> >> 2004 08 1 SA 01051100 13000 176100 00141 >> 021200 13.55 >> >> 2003 12 1 EG 01051100 10400 217185 00141 >> 021200 20.88 >> >> >> >> Having this data in mind, I wish to aggregate the above sample data >> and create new variables, through the aggregate function subcommands, >> in the aggregated data file. >> >> My break variables are (/break =impor com_no). I want generate new >> variables(the aggregated mean, median, Q1 , Q3, P5, P25, max and min >> of 'item_price' variable) in the aggregated data outfile. >> >> >> >> I tried it with this syntax but to no avail. >> >> >> >> aggregate outfile ='W:\User_xx\User_samuel\SPSS\Index\WK99\med_1b.sav' >> >> /break =imp_exp com_numb >> >> /med_pric = median(item_pri) /n=NU(item_pri) /p5= ptile(item_pri). >> >> >> >> It is imperative that the new variables min_item_price, max_item_price >> ,Q1_item_price, Q3_item_price,P5_item_price, P25_price, >> max_item_price, min_item_price are created. Creating Q1_item_price, >> Q3_item_price,P5_item_price, P25_price are still a nightmare to me. So >> have now got the picture, I couldn't make it more elucidated than this. >> >> >> >> Altimately my out put data file should look like this, >> >> >> >> Impor com_no min_item_price max_item_price Q1_item_price >> Q3_item_price P5_item_price P25_price max_item_price >> min_item_price >> >> . . . >> >> . >> >> . . >> >> . >> >> . >> >> . >> >> . >> >> >> >> >> >> Thanks, >> >> Samuel >> >> >> >> ------------------------------------------------------------------------ >> >> *From:* Art Kendall [mailto:[hidden email]] >> *Sent:* Tuesday, March 20, 2007 3:04 PM >> *To:* Samuel Solomon >> *Cc:* [hidden email] >> *Subject:* Re: percentiles,quartiles???? >> >> >> >> This is example syntax that produces quartiles, percentiles, and >> z_scores within groups. >> >> >> >> >> >> GET >> >> FILE='C:\Program Files\SPSS15\Cars.sav'. >> >> RANK VARIABLES = mpg accel horse BY origin cylinder >> >> / ntiles(4) into quart_mpg quart_accel quart_horse >> >> / percent into pct_mpg pct_accel pct_horse >> >> / normal into z_mpg z_accel z_horse. >> >> >> >> >> >> Save all your current work, then open a new instance of SPSS. >> Make sure that you put warnings, etc. into the output file. <edit> >> <options> <viewer>. Cut-and-paste then run the syntax. >> >> Does this do what you want? If not please restate your question >> in more detail. >> >> Perhaps post a small data set with variables "have" and "want". >> >> >> >> Hope this helps. >> >> >> >> Art >> >> >> >> Social Research Consultants >> >> >> >> >> >> >> >> >> >> >> >> >> > |
Free forum by Nabble | Edit this page |