# N% per variable selection

In addition to carrying out [N per variable sampling](<https://help.apteco.com/en/faststats/analysis/selections/nper-selection/index.md>), you can also carry out **N% per variable or expression sampling** in a selection. This satisfies the common requirement of sampling N% of records whilst maintaining distribution across the selected variable or expression.

## Example 1

1. Create a selection that identifies people who are Directors, Managers, or Professionals.

   [![Selection identifying Directors, Managers, and Professionals](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-Selection.png>)](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-Selection.png>)

   Imagine that of the 108,876 people identified, you are interested in creating a 10% sample based on income group - low, middle and high. If you drop a cube onto the selection above and add Income Groups as a dimension, you can see the counts of people in each group. Adding the *% Column* statistic then allows you to see the distribution of records across the categories.

   [![Cube showing Income Groups counts and percentage distribution](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-IncomeGroupsCube.png>)](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-IncomeGroupsCube.png>)

   To create a 10% sample based on income groups, whilst maintaining the distribution for the records selected, return to the selection tab and:
2. **Right click** on the selection summary row and select **Apply 'N' per 'Variable'**.

   [![Apply 'N' per Variable menu option](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-ApplyNPerVariable.png>)](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-ApplyNPerVariable.png>)
3. Click on the **People** drop-down and select **% of People** then set the required percentage - e.g. **10%**.
4. Drag and drop your **grouping variable** onto the drop-box - e.g. **Income Groups**.

   [![N% per Variable settings with 10% and Income Groups applied](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-NpercentPerVariableSettings.png>)](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-NpercentPerVariableSettings.png>)
5. Click **OK** and rebuild.

   [![Cube showing 10,888 people selected with distribution maintained across Income Groups](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-10percentIncomeGroupsCube.png>)](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-10percentIncomeGroupsCube.png>)

You can now see that 10,888 people are selected, and that the distribution across the low, middle and high income groups remains constant.

## Example 2

There may be occasions when you want to sample a specific number of records but still maintain distribution. You can achieve this using the third option in the N Per Variable dialogue - selecting **Total People**. For example, to modify and select a total of 1000 people, return to the selection tab and:

1. Right click on the selection summary row and select Modify N Per 'Variable'

   [![Modify N Per Variable menu option](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-Modify.png>)](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-Modify.png>)
2. Select **Total People** and set a total of **1000** records to be selected across **Income Groups**.

   [![Total People option set to 1000 records across Income Groups](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-TotalPeople.png>)](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-TotalPeople.png>)
3. Click **OK** and rebuild.

You can now see in the cube display that the distribution is maintained (allowing for appropriate rounding) and the number of people per income group selected accordingly.

[![Cube showing 1000 records distributed across Income Groups](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-1000RecordsCube.png>)](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/241-1000RecordsCube.png>)

When appropriate or necessary, you can group by an expression instead of a variable to carry out your sampling.

[![N% per Variable settings using an expression as the grouping variable](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/242-GroupByVariableExpression.png>)](<https://help.apteco.com/assets/images/faststats/analysis/selections/n-percent-per-variable/242-GroupByVariableExpression.png>)

Related topic:

- [Nper variable selection](<https://help.apteco.com/en/faststats/analysis/selections/nper-variable-selection/index.md>)
