Sample 42276: Delete observations when at least one value is missing
Use arrays and iterative DO loops to determine whether there are missing values across an observation. Delete the observation when a missing value is found.
Please click on the Full Code and Output tabs to see the sample and the output.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Create sample data */
data testdata;
input ch1 $ ch2 $ num1 num2 num3;
datalines;
aaa bbb 1 2 3
. bbb 1 1 1
. . . . .
aaa bbb 1 1 1
aaa bbb 1 . 2
aaa . 1 1 .
;
run;
data nomiss;
set testdata;
/* Use the reserved word _NUMERIC_ to load all numeric variables */
/* into the NUM array. Use the reserved word _CHARACTER_ to */
/* to load all character variables into the CHR array. */
array chr(*) _character_;
array num(*) _numeric_;
/* Check for missing values and delete when found. */
do i = 1 to dim(chr);
if missing(chr(i)) then delete;
end;
do j = 1 to dim(num);
if missing(num(j)) then delete;
end;
drop i j;
run;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs ch1 ch2 num1 num2 num3
1 aaa bbb 1 2 3
2 aaa bbb 1 1 1
This sample shows how to delete observations from a data set when at least one variable value across the observation is missing.
Date Modified: | 2011-02-08 10:18:03 |
Date Created: | 2011-02-03 09:07:24 |
Operating System and Release Information
SAS System | Base SAS | z/OS | | |
Z64 | | |
OpenVMS VAX | | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft® Windows® for x64 | | |
OS/2 | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2003 for x64 | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows Server 2008 for x64 | | |
Microsoft Windows XP Professional | | |
Windows 7 Enterprise 32 bit | | |
Windows 7 Enterprise x64 | | |
Windows 7 Home Premium 32 bit | | |
Windows 7 Home Premium x64 | | |
Windows 7 Professional 32 bit | | |
Windows 7 Professional x64 | | |
Windows 7 Ultimate 32 bit | | |
Windows 7 Ultimate x64 | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
Windows Vista for x64 | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
ABI+ for Intel Architecture | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |