Date: Tue, 20 Mar 2007 09:19:48 -0500
Reply-To: "Oliver, Richard" <roliver@spss.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Oliver, Richard" <roliver@spss.com>
Subject: Re: percentiles,quartiles????
In-Reply-To: A<45FFCDBF.4090009@verizon.net>
Content-Type: text/plain; charset="iso-8859-1"
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 define 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:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Art Kendall
Sent: Tuesday, March 20, 2007 7:04 AM
To: SPSSX-L@LISTSERV.UGA.EDU
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: hmaletta@fibertel.com.ar [mailto:hmaletta@fibertel.com.ar]
> 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 <samuel.solomon@nso.gov.er>
> 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
>>
>>
>>
>>
>>
>>
>
>
>
|