<font face="Courier New" color="#008000" size="2"><font face="Courier New" color="#008000" size="2"><font face="Courier New" color="#008000" size="2"><p><font color="#000000">There should be easy ways, but this is the best I can come up with.</font></p><p><font color="#000000"></font></p><p><font color="#000000">/* Assume we start with data set Original and end up with Final */<br/>/* Generate data set containing only the first two observations */<br/>proc sql inobs=2;<br/>create table test as <br/>select *<br/>from original;<br/>quit;</font></p><p><font color="#000000">/* Use Proc Means to output the missing value of each variable */<br/>proc means data=test noprint;<br/>output out=test2 nmiss=/autoname;<br/>run;</font></p><p><font color="#000000">/* Transpose the form of the data set to the form we can handle */<br/>proc transpose data=test2(drop=_TYPE_ _FREQ_) out=test3(drop=Label) NAME=Source<br/> LABEL=Label PREFIX=MIS;<br/>run;<br/>/* Get rid of the '_NMiss' at the end of the variable name to recover the original variable name */<br/>data test4;<br/>set test3;<br/> Name=trim(tranwrd(source,'_NMiss',''));<br/>run;</font></p><p><font color="#000000">/* Put the variable names in a macro, which have one or none missing value*/<br/>proc sql noprint;<br/>select Name into:keep separated by ' '<br/>from test4<br/>where mis1<2;<br/>quit;</font></p><p><font color="#000000">/* If interested, you can look at the log to see which ones were kept */<br/>%put &keep;<br/>/* Clean up the room */<br/>proc datasets nolist;<br/>delete test test1 test2 test3 test4;<br/>run;<br/>/* Keep only the good ones :-)*/<br/>data final;<br/>set original(keep=&keep);<br/>run;<br/></font></p></font></font></font>
[此贴子已经被作者于2009-4-13 22:47:46编辑过]