Tables and axes > Statistical functions and totals > Creating percentiles and medians > Percentiles based on numeric variables
 
Percentiles based on numeric variables
Quantum can calculate percentiles based on the results of numeric variables. An example is where the data contains the actual family income rather than a code representing a range of incomes. This enables you to obtain a more accurate figure by using inc= to read the values from the data. The format of percentiles with inc= is:
n01Text ;inc=variable ;percentile=factor; c=condition
For example:
n01First Quarter;inc=c(123,127);percentile=25;c=c(123,127)u$      $
This calculation uses an n01 for both the elements and the percentile: it does not use an n30.
An example of using percentile could be where you want to produce a table showing the actual family income, by region, along with the median and quartile figures. Thus, the example might read:
tab totalincome sex
l totalincome
val c(123,127);Base;hd=Household Income (in Pounds);=; 0; i;
+1-3000; 3001-6000; 6001-9000; 9001-12000; 12001-15000; 150001+
n03
n01Lower Quartile;inc=c(123,127);percentile=25;c=c(123,127)u$ $
n01Median Income;inc=c(123,127);percentile=50;c=c(123,127)u$ $
n01Upper Quartile;inc=c(123,127);percentile=75;c=c(123,127)u$ $
l sex
col 110;Base;Male;Female
The table it produces is:
                                 Base       Male     Female
Base                              464        232        232
Household Income (in pounds)
0                                  76         28         48
1-3000                             22         13          9
3001-6000                          44         11         33
6001-9000                         102         38         64
9001-12000                        144         96         48
12001-15000                        18         15          3
15001+                             58         31         27
 
Lower Quartile                   4951       7364       4451
Median Income                    8418      10002       6874
Upper Quartile                  11077      11098       9591
Note You can use the keyword median instead of percentile=50.
To request percentiles on a table, follow the rules below:
Data contains
Calculate percentiles with
Request percentiles with
Codes
Factors
fac= on elements and n30
Numeric values
Values from data
n01 and inc=
However, when you are preparing a study for Windows-based Quanvert, always specify percentiles by using fac= on the elements and the n30 statement, because Windows-based Quanvert does not produce reliable figures for percentiles that have been specified using n01 statements with inc=.
As with the other statistical statements, the percentile and median keywords suppress percentages for the row or column of percentile values.
When Quantum calculates percentiles from numeric variables, it writes information to temporary files on the disk which it then reads later in the calculation. If you see error messages about Quantum being unable to locate or open files at this point it is possible that the disk is full and the file was not created. If this happens, try to make some extra space on the disk before rerunning your job. Alternatively, remove some of the percentile requests or split the job into two smaller ones.
See also
Creating percentiles and medians