<?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: SAS base error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313965#M68310</link>
    <description>Thank you Reeza</description>
    <pubDate>Thu, 24 Nov 2016 05:31:19 GMT</pubDate>
    <dc:creator>jagadeesh_2907</dc:creator>
    <dc:date>2016-11-24T05:31:19Z</dc:date>
    <item>
      <title>SAS base error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313953#M68305</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the below error when processing a macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: eof&lt;BR /&gt;ERROR: The condition in the %DO %UNTIL loop, eof, yielded an invalid or missing value, .&amp;nbsp; The macro will stop executing.&lt;BR /&gt;ERROR: The macro MAXVAR will stop executing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code i am using is below:&lt;/P&gt;&lt;P&gt;%macro maxvar(libref,dstname,type);&lt;BR /&gt;options mprint mlogic symbolgen;&lt;BR /&gt;proc contents data = &amp;amp;libref..&amp;amp;dstname out=dst1 (keep = name type);&lt;BR /&gt;run;&lt;BR /&gt;data dst2 (keep = name);&lt;BR /&gt;set dst1;&lt;BR /&gt;where type = &amp;amp;type. ;&lt;BR /&gt;run;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select name into :varlists separated by ' '&amp;nbsp; from dst2;&lt;BR /&gt;quit;&lt;BR /&gt;%put &amp;amp;varlists. ;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select count(*) into :varcount from dst2;&lt;BR /&gt;quit;&lt;BR /&gt;%put &amp;amp;varcount.;&lt;BR /&gt;data minmax (keep = var v_min v_max);&lt;BR /&gt;array maxx(&amp;amp;varcount);&lt;BR /&gt;array minn(&amp;amp;varcount);&lt;BR /&gt;%do %until(eof);&lt;BR /&gt;set test.getrate end=eof;&lt;BR /&gt;array ch(&amp;amp;varcount) &amp;amp;varlists ;&lt;BR /&gt;%do j=1 %to &amp;amp;varcount ;&lt;BR /&gt;maxx(j)=max(maxx(j),lengthn(ch(j)));&lt;BR /&gt;minn(j)=min(minn(j),lengthn(ch(j)));&lt;BR /&gt;%end;&lt;BR /&gt;%end;&lt;BR /&gt;length var $32;&lt;BR /&gt;%do j=1 %to &amp;amp;varcount ;&lt;BR /&gt;var = vname(ch(j));&lt;BR /&gt;v_min=minn(j);&lt;BR /&gt;v_max=maxx(j);&lt;BR /&gt;output;&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just to give a idea, I am trying to find the maximum length of each character variable in a dataset. Could you please let me know what mistake i have done and what changes i need to make to remove this error.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 04:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313953#M68305</guid>
      <dc:creator>jagadeesh_2907</dc:creator>
      <dc:date>2016-11-24T04:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS base error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313957#M68307</link>
      <description>&lt;P&gt;Your do loops shouldn't be macro do loops. You don't need any do loop since that's what a datastep does. You do want a RETAIN to hold values from one line to another.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a conditional if to check if it's the last record and output the max for each variable in that case.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As always you should create a macro off code that works in base SAS - remove all macro portions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your array declaration is also incorrect as it doesn't have a $ to indicate character. You can avoid a good portion of the first step of your code by using _numeric_ and _character_ to reference all numeric or character variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 05:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313957#M68307</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-24T05:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS base error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313960#M68308</link>
      <description>&lt;P&gt;Thank you. I am bit confused on where to use the loops as macro and where can i use the normal loops. Could you please provide some tips for me on the same.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 05:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313960#M68308</guid>
      <dc:creator>jagadeesh_2907</dc:creator>
      <dc:date>2016-11-24T05:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS base error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313963#M68309</link>
      <description>&lt;P&gt;In general use macro loops to repeat a proc or datastep.&lt;/P&gt;
&lt;P&gt;It could also be used to generate statements that can't be done via a data step for some reason, for example the lag function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Within a datastep use a standard do loop.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 05:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313963#M68309</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-24T05:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS base error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313965#M68310</link>
      <description>Thank you Reeza</description>
      <pubDate>Thu, 24 Nov 2016 05:31:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-base-error/m-p/313965#M68310</guid>
      <dc:creator>jagadeesh_2907</dc:creator>
      <dc:date>2016-11-24T05:31:19Z</dc:date>
    </item>
  </channel>
</rss>

