### Aptech Systems, Inc. Worldwide Headquarters

Address:

Aptech Systems, Inc.

2350 East Germann Road, Suite #21

Chandler, AZ 85286Phone: 360.886.7100

FAX: 360.886.8922**Ready to Get Started?**### Request Quote & Product Information

### Industry Solutions

### Products

### Resources

### Support

### Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

### Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

### Have a Specific Question?

### Q&A: Register and Login

### Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

### User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!

### Where to Buy

Available across the globe, you can have access to GAUSS no matter where you are.

### Recent Tags

applications character vectors CML CMLMT Constrained Optimization datasets dates dlibrary dllcall econometrics Editor error error codes errors Excel file i/o floating network GAUSS Engine GAUSS Light graphics GUI hotkeys installation license licensing linux loading data loop loops matrix manipulation Maximum Likelihood Maxlik MaxLikMT Memory multidimensional array optimization Optmum output panel data PQG graphics procs random numbers strings structures threading### Recent Questions

- How to run Narayan and Popp (2010) unit root test with two structural break
- ThreadFor again
- cml.lcg zip file
- nelder-mead optimization algorithm
- Kernel regression - kreg
- exponential matrix
- Panel unit root test with structural breaks - calculating break dates
- Panel unit root test with structural breaks. A problem with the code
- creating subplot
- Output for each loop - output names are also looped

### Features

### Time Series 2.0 MT

### Industry Solutions

### Find out more now

### Time Series MT 2.1

### Find out more now

### Find out more now

# Resources

# HOW TO DROP TOP 5% OBSERVATIONS IN YOUR DATA

Hello,

I am a new user to Gauss, could you please tell me how can i drop the top 5% observations of my data set, I did not find any code related to this. But I think I can line up all the observations and delete the 5%* the number of observations' rows in the end.

Can anyone help me with this?

Thank you very much

## 1 Answer

I am not certain that I am understanding your question correctly. Below is something that may help you. If it does not answer your question, let us know and we will be happy to provide more help.

**Deleting the first 5% of your observations**

Let us suppose that we have one variable with 100 observations. For our example, we will create a random normal vector to represent this variable. We can remove the first 5% of observations by using an indexing operation to select the final 95% like this:

//create example variable x_1 = rndn(100, 1); //assign 'x_1' to equal the last 95% of observations x_1 = x_1[6:100];

Since we will not always have 100 observations and would like code that works even if we get more data, we should make the code more abstract. In this next code snippet, we will use the `rows` function to calculate the length of our vector and the `ceil` function to round up in case 5% of our total number of rows is not a whole number.

//create example variable x_1 = rndn(100, 1); //calculate index of first row we want to keep start_idx = ceil(rows(x_1) * 0.05); //assign 'x_1' to equal the last 95% of observations x_1 = x_1[start_idx:rows(x)];

## Your Answer

## 1 Answer

I am not certain that I am understanding your question correctly. Below is something that may help you. If it does not answer your question, let us know and we will be happy to provide more help.

**Deleting the first 5% of your observations**

Let us suppose that we have one variable with 100 observations. For our example, we will create a random normal vector to represent this variable. We can remove the first 5% of observations by using an indexing operation to select the final 95% like this:

//create example variable x_1 = rndn(100, 1); //assign 'x_1' to equal the last 95% of observations x_1 = x_1[6:100];

Since we will not always have 100 observations and would like code that works even if we get more data, we should make the code more abstract. In this next code snippet, we will use the `rows` function to calculate the length of our vector and the `ceil` function to round up in case 5% of our total number of rows is not a whole number.

//create example variable x_1 = rndn(100, 1); //calculate index of first row we want to keep start_idx = ceil(rows(x_1) * 0.05); //assign 'x_1' to equal the last 95% of observations x_1 = x_1[start_idx:rows(x)];