<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Base SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/392439#M94426</link>
    <description>&lt;P&gt;What you are describing as your objective is a simple DATA step, not a complex macro. &amp;nbsp;The only complication to worry about is determining that you have both character and numeric variables in your data set. &amp;nbsp;Here's what the final program would look like, when you know you have a mix:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set have end=done;&lt;/P&gt;
&lt;P&gt;array charvars {*} _character_;&lt;/P&gt;
&lt;P&gt;array numvars {*} _numeric_;&lt;/P&gt;
&lt;P&gt;do _n_=1 to dim(charvars);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if charvars{_n_} = " " then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; put 'ABORT: &amp;nbsp;Found a Missing Character Variable';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stop;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do _n_=1 to dim(numvars);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if numvars{_n_} = . then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; put 'ABORT: &amp;nbsp;Found a Missing Numeric Variable';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stop;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;if done;&lt;/P&gt;
&lt;P&gt;put 'PROCEED: &amp;nbsp;No Missing Values Found';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only tricky part that macro language might automate is constructing lists of which variables belong in which array. &amp;nbsp;Other than that, macro language doesn't come into play. &amp;nbsp;(If there are no numeric variables, for example, creating an array with _NUMERIC_ as the variable list will create an error condition.) &amp;nbsp;But we'll leave that for a separate question if you actually have to overcome that problem.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Sep 2017 06:27:46 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-09-01T06:27:46Z</dc:date>
    <item>
      <title>Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/392436#M94424</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to do the following - Loop through a list of 5 variables in a given dataset and if any value in missing ( . or " ") Then Flag_1 = "ABORT" or ... Flag_5 =&amp;nbsp;&lt;SPAN&gt;"ABORT"; Next, if any of the 5 flags is "ABORT" then PROC SQL prints message : ABORT, else PROCEED if all FLAGS are "PROCEED".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt; Imports (Sheet, Out);&lt;/P&gt;
&lt;P&gt;PROC&amp;nbsp; IMPORT&amp;nbsp; OUT= &amp;amp;Out.&lt;/P&gt;
&lt;P&gt;DATAFILE=&amp;nbsp; "&amp;amp;library.\&amp;amp;Sheet..xlsx" DBMS=XLSX REPLACE;&lt;/P&gt;
&lt;P&gt;GETNAMES=YES;&lt;/P&gt;
&lt;P&gt;MIXED=NO;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA &amp;amp;Out.; SET &amp;amp;Out.;&lt;/P&gt;
&lt;P&gt;if Var1 = " " &amp;nbsp;then Flag = "ABORT"; ELSE Flag = "PROCEED";&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data = &amp;amp;Out. ; TABLES Flag/ OUT = Cont_&amp;amp;Out. LIST MISSING NOROW NOCOL NOCUM NOPERCENT;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL noprint;&lt;/P&gt;
&lt;P&gt;SELECT DISTINCT FLAG INTO : FLAG2 separated BY " " FROM Cont_&amp;amp;Out.;&lt;/P&gt;
&lt;P&gt;%if %INDEX(COMPRESS(&amp;amp;FLAG2.) , "ABORT") &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; %then %DO ;%PUT ABORT: MISSING VAR1; %END;&lt;/P&gt;
&lt;P&gt;%else %if %INDEX(COMPRESS(&amp;amp;FLAG2.) , "ABORT") = &lt;STRONG&gt;0&lt;/STRONG&gt; %then %DO; %PUT PROCEED : &lt;SPAN&gt;VAR1&amp;nbsp;&lt;/SPAN&gt;FULLY POPULATED;%END;&lt;/P&gt;
&lt;P&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;FLAG2.;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;Imports&lt;/EM&gt;&lt;/STRONG&gt; (dataset, &lt;SPAN&gt;dataset&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help above code gives error as it does not read the ABORT in INDEX function. Also, is it possible to have a loop / array within macro to loop through all 5 variables in dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind Regards&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 05:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/392436#M94424</guid>
      <dc:creator>Siddharth123</dc:creator>
      <dc:date>2017-09-01T05:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/392439#M94426</link>
      <description>&lt;P&gt;What you are describing as your objective is a simple DATA step, not a complex macro. &amp;nbsp;The only complication to worry about is determining that you have both character and numeric variables in your data set. &amp;nbsp;Here's what the final program would look like, when you know you have a mix:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set have end=done;&lt;/P&gt;
&lt;P&gt;array charvars {*} _character_;&lt;/P&gt;
&lt;P&gt;array numvars {*} _numeric_;&lt;/P&gt;
&lt;P&gt;do _n_=1 to dim(charvars);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if charvars{_n_} = " " then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; put 'ABORT: &amp;nbsp;Found a Missing Character Variable';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stop;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do _n_=1 to dim(numvars);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if numvars{_n_} = . then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; put 'ABORT: &amp;nbsp;Found a Missing Numeric Variable';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stop;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;if done;&lt;/P&gt;
&lt;P&gt;put 'PROCEED: &amp;nbsp;No Missing Values Found';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only tricky part that macro language might automate is constructing lists of which variables belong in which array. &amp;nbsp;Other than that, macro language doesn't come into play. &amp;nbsp;(If there are no numeric variables, for example, creating an array with _NUMERIC_ as the variable list will create an error condition.) &amp;nbsp;But we'll leave that for a separate question if you actually have to overcome that problem.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 06:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/392439#M94426</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-01T06:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/392444#M94430</link>
      <description>&lt;P&gt;I don't understand what you want.&lt;/P&gt;
&lt;P&gt;It sounded like you want to stop if ANY of the variables have ANY missing values?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let abort=0;
data _null_;
  set have ;
  if cmiss(of _all_) then do;
    call symputx('abort',1);
   stop;
 end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mixing in the PROC IMPORT step into the macro doesn't really help as I don't think that is part of your actual problem. You can always add that back later once you get code to do the tricky part.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 07:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-SAS/m-p/392444#M94430</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-01T07:15:52Z</dc:date>
    </item>
  </channel>
</rss>

