<?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: LOOP ERROR - possibly data type reference error? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552695#M153648</link>
    <description>Thank you very much for the solution! Amazing, it works.</description>
    <pubDate>Sun, 21 Apr 2019 12:21:34 GMT</pubDate>
    <dc:creator>ptr_joo</dc:creator>
    <dc:date>2019-04-21T12:21:34Z</dc:date>
    <item>
      <title>LOOP ERROR - possibly data type reference error?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552411#M153560</link>
      <description>&lt;P&gt;libname mask xxxxxxxxxx;&lt;BR /&gt;%let pathway = xxxxxxxxxx;&lt;BR /&gt;&lt;BR /&gt;%macro maxmin;&lt;BR /&gt;/* get variable names */&lt;BR /&gt;proc contents noprint data = &amp;amp;pathway out=contents&lt;BR /&gt;;run;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;create table contents_char as&lt;BR /&gt;select * from contents where type = 2&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select count(*) into: cnt from contents_char&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;%let cnt = &amp;amp;cnt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select name into: name1 - : name&amp;amp;cnt from contents_char&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;/*get periods into an array*/&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select count(distinct reporting_period) into: cnt_p from &amp;amp;pathway&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;create table reporting_period_sorted as&lt;BR /&gt;select distinct reporting_period from &amp;amp;pathway order by reporting_period desc&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;%let cnt_p = &amp;amp;cnt_p;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select reporting_period into: period1 - : period&amp;amp;cnt_p from reporting_period_sorted&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;/*get product types into an array*/&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select count(distinct product_ccar_type) into: cnt_pr from &amp;amp;pathway /*where product_ccar_type is not null*/&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;create table product_ccar_type as&lt;BR /&gt;select distinct product_ccar_type from &amp;amp;pathway /*where product_ccar_type is not null*/&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;%let cnt_pr = &amp;amp;cnt_pr;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select product_ccar_type into: product1 - : product&amp;amp;cnt_pr from product_ccar_type /*where product_ccar_type is not null*/&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;/*delete results*/&lt;/P&gt;&lt;P&gt;proc delete data = results;run;&lt;/P&gt;&lt;P&gt;/*looping through the periods*/&lt;BR /&gt;%do j = 1 %to 1 /*&amp;amp;cnt_p*/;&lt;/P&gt;&lt;P&gt;%let period_len = 6;&lt;/P&gt;&lt;P&gt;/*looping through the products*/&lt;BR /&gt;%do k = 1 %to 1 /*&amp;amp;cnt_pr*/;&lt;/P&gt;&lt;P&gt;%let product_len = 5;&lt;/P&gt;&lt;P&gt;/* get length of all variable names and results */&lt;BR /&gt;%let name_len = 0;&lt;BR /&gt;%let count_len = 0;&lt;BR /&gt;%let countd_len = 0;&lt;BR /&gt;%let countnull_len = 0;&lt;/P&gt;&lt;P&gt;%do i = 1 %to &amp;amp;cnt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select count(&amp;amp;&amp;amp;name&amp;amp;i), count(distinct &amp;amp;&amp;amp;name&amp;amp;i), sum(case when &amp;amp;&amp;amp;name&amp;amp;i is null then 1 else 0 end)&lt;BR /&gt;into :count&amp;amp;i, :countd&amp;amp;i, :countnull&amp;amp;i&lt;BR /&gt;from &amp;amp;pathway&lt;BR /&gt;where reporting_period = put(&amp;amp;&amp;amp;period&amp;amp;j, 6.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;and product_ccar_type in ('CA_BC')&amp;nbsp; - IT WORKS&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="5"&gt;and product_ccar_type = put(&amp;amp;&amp;amp;product&amp;amp;k, 10.) - IT GIVES ERROR:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="book antiqua,palatino"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="book antiqua,palatino"&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="book antiqua,palatino"&gt;a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER. &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let count&amp;amp;i = %cmpres(&amp;amp;&amp;amp;count&amp;amp;i);&lt;BR /&gt;%let countd&amp;amp;i = %cmpres(&amp;amp;&amp;amp;countd&amp;amp;i);&lt;BR /&gt;%let countnull&amp;amp;i = %cmpres(&amp;amp;&amp;amp;countnull&amp;amp;i);&lt;/P&gt;&lt;P&gt;%if (&amp;amp;name_len &amp;lt; %length(&amp;amp;&amp;amp;name&amp;amp;i)) %then %let name_len = %length(&amp;amp;&amp;amp;name&amp;amp;i);&lt;BR /&gt;%if (&amp;amp;count_len &amp;lt; %length(&amp;amp;&amp;amp;count&amp;amp;i)) %then %let count_len = %length(&amp;amp;&amp;amp;count&amp;amp;i);&lt;BR /&gt;%if (&amp;amp;countd_len &amp;lt; %length(&amp;amp;&amp;amp;countd&amp;amp;i)) %then %let countd_len = %length(&amp;amp;&amp;amp;countd&amp;amp;i);&lt;BR /&gt;%if (&amp;amp;countnull_len &amp;lt; %length(&amp;amp;&amp;amp;countnull&amp;amp;i)) %then %let countnull_len = %length(&amp;amp;&amp;amp;countnull&amp;amp;i);&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*create results */&lt;BR /&gt;%do i = 1 %to &amp;amp;cnt;&lt;BR /&gt;data temp;&lt;BR /&gt;length PERIOD $&amp;amp;period_len PRODUCT $&amp;amp;product_len NAME $&amp;amp;name_len COUNT $&amp;amp;count_len COUNTD $&amp;amp;countd_len COUNTNULL $&amp;amp;countnull_len;&lt;BR /&gt;PERIOD = "&amp;amp;&amp;amp;period&amp;amp;j";&lt;BR /&gt;PRODUCT ="&amp;amp;&amp;amp;product&amp;amp;k";&lt;BR /&gt;NAME = "&amp;amp;&amp;amp;name&amp;amp;i";&lt;BR /&gt;COUNT = "&amp;amp;&amp;amp;count&amp;amp;i";&lt;BR /&gt;COUNTD = "&amp;amp;&amp;amp;countd&amp;amp;i";&lt;BR /&gt;COUNTNULL = "&amp;amp;&amp;amp;countnull&amp;amp;i";&lt;BR /&gt;run;&lt;BR /&gt;proc append base = results data= temp force&lt;BR /&gt;;run;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend maxmin;&lt;BR /&gt;%maxmin;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 08:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552411#M153560</guid>
      <dc:creator>ptr_joo</dc:creator>
      <dc:date>2019-04-19T08:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP ERROR - possibly data type reference error?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552413#M153561</link>
      <description>&lt;PRE&gt;&amp;amp;&amp;amp;product&amp;amp;k&lt;/PRE&gt;
&lt;P&gt;should resolve either to the name of a numeric column, or to a number.&lt;/P&gt;
&lt;P&gt;Run your code again with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mlogic mprint symbolgen;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to get all available information for macro debugging.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 09:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552413#M153561</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-19T09:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP ERROR - possibly data type reference error?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552688#M153642</link>
      <description>&lt;P&gt;Thanks for the answer. I have made the modifications suggested, however, I cannot find the solution yet. I am trying to describe the issue properly with attaching the outcome, maybe it helps :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I am constructing a loop by defining an array and taking its values from a specific column in the master table. (let's choose 'CA_BC' record as an example)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where reporting_period = put(&amp;amp;&amp;amp;period&amp;amp;j, 6.)&lt;BR /&gt;and &lt;U&gt;&lt;STRONG&gt;product_ccar_type = &amp;amp;&amp;amp;product&amp;amp;k&lt;/STRONG&gt;&lt;/U&gt; /* distinct values : CA_BC, CA_CC, CA_OC, CO_UI, RE_FR, OTH, RE_HE*/&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. The macro stops with the following message - even if the loop takes 'CA_BC', it cannot find it, however, this value is taken from that very master table:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable K resolves to 1&lt;BR /&gt;SYMBOLGEN: Macro variable &lt;STRONG&gt;PRODUCT1 resolves to CA_BC&lt;/STRONG&gt;&lt;BR /&gt;MPRINT(MAXMIN): select count(ACCOUNT_NUMBER), count(distinct ACCOUNT_NUMBER), sum(case when ACCOUNT_NUMBER is null then 1 else 0&lt;BR /&gt;end) into :count1, :countd1, :countnull1 from mask.mis_coe_au where reporting_period = put(201812, 6.) and &lt;STRONG&gt;product_ccar_type = &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CA_BC&lt;/STRONG&gt; ;&lt;BR /&gt;&lt;FONT size="3"&gt;&lt;STRONG&gt;ERROR: The following columns were not found in the contributing tables: CA_BC.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;3. If I change the code from&amp;nbsp;product_ccar_type = &amp;amp;&amp;amp;product&amp;amp;k to&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;product_ccar_type = ('CA_BC')&lt;/STRONG&gt;&lt;/U&gt;, it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2019 11:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552688#M153642</guid>
      <dc:creator>ptr_joo</dc:creator>
      <dc:date>2019-04-21T11:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP ERROR - possibly data type reference error?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552694#M153647</link>
      <description>Add double quotes around the expression:&lt;BR /&gt;&lt;BR /&gt;and product_ccar_type = "&amp;amp;&amp;amp;product&amp;amp;k"</description>
      <pubDate>Sun, 21 Apr 2019 12:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552694#M153647</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-21T12:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP ERROR - possibly data type reference error?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552695#M153648</link>
      <description>Thank you very much for the solution! Amazing, it works.</description>
      <pubDate>Sun, 21 Apr 2019 12:21:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LOOP-ERROR-possibly-data-type-reference-error/m-p/552695#M153648</guid>
      <dc:creator>ptr_joo</dc:creator>
      <dc:date>2019-04-21T12:21:34Z</dc:date>
    </item>
  </channel>
</rss>

