<?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: Using macro(?) for length of character and Apparent symbolic reference not resolved error. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544431#M7847</link>
    <description>&lt;P&gt;&lt;BR /&gt;I can't thank you enough, Tom! I've been battling with this for the last couple of days!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is so much simpler and works great!&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2019 02:35:40 GMT</pubDate>
    <dc:creator>tonoplast</dc:creator>
    <dc:date>2019-03-20T02:35:40Z</dc:date>
    <item>
      <title>Using macro(?) for length of character and Apparent symbolic reference not resolved error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544424#M7841</link>
      <description>&lt;P&gt;Hi everyone.&lt;/P&gt;&lt;P&gt;I am new to SAS, and this is my first post. I hope that this post would not frustrate experienced coders.&lt;/P&gt;&lt;P&gt;I'm using SAS Enterprise Guide 7.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been battling with using CHAR and NUM from table/macro and use them in the iteration.&lt;/P&gt;&lt;P&gt;What I want to do eventually is to use each row of variables (char) and (num) to change the length of characters of different columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For now, I have done:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data varlentable;&lt;/P&gt;&lt;P&gt;input name $ mlen;&lt;/P&gt;&lt;P&gt;AAA 1&lt;/P&gt;&lt;P&gt;BBB 4&lt;/P&gt;&lt;P&gt;CCC 4&lt;/P&gt;&lt;P&gt;DDD 8&lt;/P&gt;&lt;P&gt;EEE 10&lt;/P&gt;&lt;P&gt;FFF 12&lt;/P&gt;&lt;P&gt;GGG 15&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select name&lt;/P&gt;&lt;P&gt;into: names&lt;/P&gt;&lt;P&gt;separated by ','&lt;/P&gt;&lt;P&gt;from varlentable;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select mlen&lt;/P&gt;&lt;P&gt;into: CL separated by ','&lt;/P&gt;&lt;P&gt;from varlentable;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put &amp;amp;names.;&lt;/P&gt;&lt;P&gt;%put &amp;amp;CL.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;set varlentable;&lt;/P&gt;&lt;P&gt;do i = 1 by 1 while(scan("&amp;amp;names.",i) ne ' ');&lt;/P&gt;&lt;P&gt;thisnum = scan("&amp;amp;CL.",i,',');&lt;/P&gt;&lt;P&gt;thischar = scan("&amp;amp;names.",i,',');&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;This creates 'test' table and it seems to work.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;/P&gt;&lt;P&gt;length thischar $ thisnum.; /* if i put $1 for example, it works*/&lt;/P&gt;&lt;P&gt;set varlentable;&lt;/P&gt;&lt;P&gt;do i = 1 by 1 while(scan("&amp;amp;names.",i) ne ' ');&lt;/P&gt;&lt;P&gt;thisnum = scan("&amp;amp;CL.",i,',');&lt;/P&gt;&lt;P&gt;thischar = scan("&amp;amp;names.",i,',');&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;This doesn't work and says:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;length this char $ &amp;amp;thisnum.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Warning: Apparent symbolic reference THISNUM not resolved.&lt;/P&gt;&lt;P&gt;Expecting a variable length specification.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not been able to resolve this issue. Please help. What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 02:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544424#M7841</guid>
      <dc:creator>tonoplast</dc:creator>
      <dc:date>2019-03-20T02:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro(?) for length of character and Apparent symbolic reference not resolved error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544427#M7843</link>
      <description>&lt;P&gt;Can you please post the exact code and log?&lt;BR /&gt;Make sure to specify the macro debugging options such as MPRINT and SYMBOLGEN to get the full information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264091"&gt;@tonoplast&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone.&lt;/P&gt;
&lt;P&gt;I am new to SAS, and this is my first post. I hope that this post would not frustrate experienced coders.&lt;/P&gt;
&lt;P&gt;I'm using SAS Enterprise Guide 7.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been battling with using CHAR and NUM from table/macro and use them in the iteration.&lt;/P&gt;
&lt;P&gt;What I want to do eventually is to use each row of variables (char) and (num) to change the length of characters of different columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For now, I have done:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data varlentable;&lt;/P&gt;
&lt;P&gt;input name $ mlen;&lt;/P&gt;
&lt;P&gt;AAA 1&lt;/P&gt;
&lt;P&gt;BBB 4&lt;/P&gt;
&lt;P&gt;CCC 4&lt;/P&gt;
&lt;P&gt;DDD 8&lt;/P&gt;
&lt;P&gt;EEE 10&lt;/P&gt;
&lt;P&gt;FFF 12&lt;/P&gt;
&lt;P&gt;GGG 15&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select name&lt;/P&gt;
&lt;P&gt;into: names&lt;/P&gt;
&lt;P&gt;separated by ','&lt;/P&gt;
&lt;P&gt;from varlentable;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select mlen&lt;/P&gt;
&lt;P&gt;into: CL separated by ','&lt;/P&gt;
&lt;P&gt;from varlentable;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;names.;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;CL.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;set varlentable;&lt;/P&gt;
&lt;P&gt;do i = 1 by 1 while(scan("&amp;amp;names.",i) ne ' ');&lt;/P&gt;
&lt;P&gt;thisnum = scan("&amp;amp;CL.",i,',');&lt;/P&gt;
&lt;P&gt;thischar = scan("&amp;amp;names.",i,',');&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop i;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;This creates 'test' table and it seems to work.&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;/P&gt;
&lt;P&gt;length thischar $ thisnum.; /* if i put $1 for example, it works*/&lt;/P&gt;
&lt;P&gt;set varlentable;&lt;/P&gt;
&lt;P&gt;do i = 1 by 1 while(scan("&amp;amp;names.",i) ne ' ');&lt;/P&gt;
&lt;P&gt;thisnum = scan("&amp;amp;CL.",i,',');&lt;/P&gt;
&lt;P&gt;thischar = scan("&amp;amp;names.",i,',');&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop i;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;This doesn't work and says:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;length this char $ &amp;amp;thisnum.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warning: Apparent symbolic reference THISNUM not resolved.&lt;/P&gt;
&lt;P&gt;Expecting a variable length specification.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have not been able to resolve this issue. Please help. What am I doing wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;S&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 02:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544427#M7843</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-20T02:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro(?) for length of character and Apparent symbolic reference not resolved error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544429#M7845</link>
      <description>&lt;P&gt;Of course something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length thischar $ thisnum.; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;doesn't work. It makes no sense. The LENGTH statement wants numbers for the length, not variable names (actually that looks more like you are trying to reference a character format).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not just generate the NAME/LENGTH pairs directly from your metadata table?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select catx(' ',name,cats('$',mlen))
    into :lengths separated by ' '
  from varlentable
  ;
quit;

data want;
  length &amp;amp;lengths;
  set have;
run;&lt;/CODE&gt;&lt;/PRE&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>Wed, 20 Mar 2019 02:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544429#M7845</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-20T02:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro(?) for length of character and Apparent symbolic reference not resolved error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544431#M7847</link>
      <description>&lt;P&gt;&lt;BR /&gt;I can't thank you enough, Tom! I've been battling with this for the last couple of days!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is so much simpler and works great!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 02:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544431#M7847</guid>
      <dc:creator>tonoplast</dc:creator>
      <dc:date>2019-03-20T02:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using macro(?) for length of character and Apparent symbolic reference not resolved error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544510#M7861</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select catx(' ',name,cats('char(',mlen,')'))
    into :lengths separated by ','
  from varlentable
  ;
alter table have
modify &amp;amp;varlentable ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Mar 2019 11:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-macro-for-length-of-character-and-Apparent-symbolic/m-p/544510#M7861</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-03-20T11:06:50Z</dc:date>
    </item>
  </channel>
</rss>

