Generally, when we import data from external sources such as Excel/CSV files, it loads additional rows that are totally blank. Sometimes empty values in the database also affect the desired output so it’s necessary to check missing cases and perform operations accordingly
Example:
Input: The sample dataset looks like below have four variables – 1 character and 3 numeric. It would be used further in the example to demonstrate how to remove empty rows.
| Name | Phys | Chem | Maths |
|---|---|---|---|
| Shubhash | 70 | 68 | 66 |
| – | |||
| Samar | 55 | 85 | |
| Ashutosh | 54 | 78 | 89 |
| – | |||
| Varun | 50 | 96 | 85 |
| Pratiksha | 68 | 93 |
Create a SAS dataset
The below defined code is a sample dataset to perform delete empty operation.
data outdata; LENGTH name $12.; input name $ phys chem maths ; infile datalines missover; datalines;Shubhash 70 68 66 samar 55 . 85 ashutosh 54 78 89 varun 50 96 85 pratiksha . 68 93 ;run; |
Output:

- Method I: Removes complete row where all variables having blank/missing values
OPTIONS missing =' ';data readin;SEToutdata;IF missing(cats(of_all_))THENDELETE;run;chevron_rightfilter_noneNote:
- The MISSING= system option is used to display the missing values as a single space rather than as the default period (.) options missing = ‘ ‘;
- The CATS function concatenates the values. It also removes leading and trailing blanks. cats(of _all_) – Concatenate all the variables
- missing(cats(of _all_)) – Identifies all the rows in which missing values exist in all the variables.
Output:

- Method II: Removes only that rows where any of the variable has missing/blank values
data readin;SEToutdata;IF cmiss(of_character_)ORnmiss(of_numeric_) > 0THENDELETE;run;chevron_rightfilter_noneIn this case, we are using the OR operator to check if any of the variables have missing values. It returns 4 observations. Check out the output below –

Recommended Posts:
- Binding rows and columns of a Data Frame in R - bind_rows() and bind_cols() Function
- How to Learn Python in 21 Days?
- Top Programming Languages for Data Science in 2020
- Top 5 Most Loved Programming Languages in 2020
- What happens when we call a Function
- Matrix operations using operator overloading
- How to take input in Octave GNU?
- Switch case statement in Octave GNU
- Comments in Octave GNU
- How to output in Octave GNU
- C Programming For Beginners - A 20 Day Curriculum!
- Python vs Java - Who Will Win the Battle in 2020?
- What is Standard Meta Language (SML)?
- Difference between C and Objective C
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

