<?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: Syntax Error for length? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/385135#M92092</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;But I still don't understand what is the purpose for&amp;nbsp;using "&amp;nbsp;5. - L " ?&amp;nbsp; Where is Name from?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So in your original code you had this line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select name, put(count(name),5.-L) into :clist separated by ' ' , :charct&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The 5. is the format and the -L is format modifier that says to Left align the value. So when the number being PUT() is less than 100,000 the spaces are at the end instead of the beginning. &amp;nbsp;The reason it was used was to a create macro variable that did not have spaces in the beginning. &amp;nbsp;As I said before that is not really how you should do this. &amp;nbsp;You could instead use the TRIMMED keyword.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select name, count(name)
  into :clist separated by ' ' , :charct trimmed&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or even better just use the automatic macro variable SQLOBS which will have the count.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select name  into :clist separated by ' '  .... ;
%let charct=&amp;amp;sqlobs;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Later in the program there appears to be another attempt to perhaps use the -L format modifier:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('var'||put(cnt, len-l),vname(char(i)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But that use is syntacticly incorrect. The PUT function wants a format &lt;SPAN&gt;specification&amp;nbsp;&lt;/SPAN&gt;, not an expression. Even if you change to the PUTN() function which takes the format specification from a character variable or expression you still wouldn't want to use the varaible LEN as it has no meaning. &amp;nbsp;You could just hard code it to something that is long enough for any possible value of CNT, like the 5. in the SQL statement.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('var'||put(cnt, 5.-L),vname(char(i)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you were trying to do this NOW you wouldn't use that syntax. &amp;nbsp;Use the CATS() function to append a numberic suffix onto a base name. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx(cats('var',cnt),vname(char(i)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you wanted a numeric suffix that was more than 12 digits long ( that is a number larger than 999,999,999,999) then you could use the PUT() or PUTN() function. &amp;nbsp;So since your prefix, VAR, is three characters long and a SAS name can only be 32 characters long so you could support a numeric suffix of up to 29 digits (if SAS could actually represent a number that large distinctly).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx(cats('var',put(cnt,29.)),vname(char(i)));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 02 Aug 2017 22:07:36 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-08-02T22:07:36Z</dc:date>
    <item>
      <title>Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384438#M91878</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Hello:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;I have&amp;nbsp;some questions from the program below.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;1. The code for '&lt;FONT face="Courier New" size="2"&gt;put(count(name),&lt;/FONT&gt;&lt;FONT color="#ff0000" face="Courier New" size="2"&gt;5.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT color="#ff0000"&gt;-L&lt;/FONT&gt;)',&amp;nbsp; what&amp;nbsp;are &lt;FONT color="#ff0000"&gt;5.&lt;/FONT&gt; and &lt;FONT color="#ff0000"&gt;L&lt;/FONT&gt; represent for?&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;2. I am trying to identify the length of all the columns and use them in the call symput statement,&amp;nbsp; I know I was NOT&amp;nbsp;doing in the correct way.&amp;nbsp; However, I don't know how.&amp;nbsp; Please advice to fix it.&amp;nbsp; Thanks.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; work.ds1; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a s d z $ x $ c $;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;1 . 3 qwe . yui&lt;/P&gt;
&lt;P&gt;. . . . . hjk&lt;/P&gt;
&lt;P&gt;3 . 3 zxc . .&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; lib=WORK;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; mem=DS1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; name, put(count(name),&lt;/FONT&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;5.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT color="#ff0000"&gt;-L&lt;/FONT&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; :clist separated &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; , :charct&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dictionary.columns&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; libname=upcase(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;lib"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; memname=upcase(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;mem"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; type=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'char'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;clist;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; truefalse;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; char(*) $ &amp;amp;clist;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; c_allmiss (&amp;amp;charct) $ (&amp;amp;charct*&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'true'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;mem &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=done;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;len=length(name);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dim(c_allmiss);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; char(i) ne &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; c_allmiss(i)=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'false'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; done &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; cnt=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dim(c_allmiss);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; c_allmiss(i) =&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'true'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; cnt+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'var'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;||put(cnt, &lt;FONT color="#ff0000"&gt;len&lt;/FONT&gt;-l),vname(char(i)));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&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; ---&lt;/P&gt;
&lt;P&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; 85&lt;/P&gt;
&lt;P&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; 76&lt;/P&gt;
&lt;P&gt;ERROR 85-322: Expecting a format name.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 20:45:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384438#M91878</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-31T20:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384441#M91879</link>
      <description>&lt;P&gt;Can you please comment your code so we understand what you think it's doing/should be doing?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 20:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384441#M91879</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-31T20:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384442#M91880</link>
      <description>&lt;P&gt;Remove the Blank in all of the Charater columns&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 20:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384442#M91880</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-31T20:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384448#M91881</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;5. is a format&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;-L means left justified.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT size="2" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;symput(&lt;/FONT&gt;&lt;FONT size="2" color="#800080"&gt;'var'&lt;/FONT&gt;&lt;FONT size="2"&gt;||put(cnt,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#ff0000"&gt;len&lt;/FONT&gt;-l),vname(char(i)));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;causes an error, because you did not specify a format. &amp;nbsp;Using PUT and || in this kind of context (even if it were used correctly) strikes me as old fashioned. &amp;nbsp;This is an easier way to create a name from a string and an integer:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT size="2" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;symputx(cats(&lt;FONT size="2" color="#800080"&gt;'var',&lt;/FONT&gt;cnt),vname(char(i)));&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 21:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384448#M91881</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-07-31T21:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384454#M91882</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Hello:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;I have&amp;nbsp;some questions from the program below.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;1. The code for '&lt;FONT face="Courier New" size="2"&gt;put(count(name),&lt;/FONT&gt;&lt;FONT color="#ff0000" face="Courier New" size="2"&gt;5.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT color="#ff0000"&gt;-L&lt;/FONT&gt;)',&amp;nbsp; what&amp;nbsp;are &lt;FONT color="#ff0000"&gt;5.&lt;/FONT&gt; and &lt;FONT color="#ff0000"&gt;L&lt;/FONT&gt; represent for?&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The 5. , and the period is important, is the Format used to put the numeric value, short hand for a F5,0 format&amp;nbsp;meaning fixed 5 positions output with none in the decimal positions&amp;nbsp;and the L says to justify the output left in the 5 characters.&lt;/P&gt;
&lt;P&gt;If you use the code below:&lt;/P&gt;
&lt;PRE&gt;data have;
  str= put (15, f5.0)  ;
  str2= put (15, f5.0 -L)  ;
  l1= length(str);
  l2= length(str2);
run;&lt;/PRE&gt;
&lt;P&gt;you will note that the two STR variables have different lengths, L1 and L2. The first will have leading blanks as part of the value the the second not.&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;
&lt;P&gt;If I understand the approach you are needing you need&amp;nbsp;a different&amp;nbsp;array to hold the values of the lengths of each of the individual variables, the same number of elements as the names. BTW, since there is a Function named CHAR I would suggest not useing it as an array name as you might get unexpected results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you need to use a different function to examine the value of a variable when you have the name in an array:&lt;/P&gt;
&lt;PRE&gt;data truefalse;
   Set &amp;amp;lib..&amp;amp;mem ;
   array _c_(*) $ &amp;amp;clist;
   array len (&amp;amp;charct);
   retain Len: ;

   do i= 1 to dim(_c_);
      Len[i]= length(vvalue(_c_[i]));
   end;
run;&lt;/PRE&gt;
&lt;P&gt;I left out the c_allmiss as I had no idea how you were meaning to use it. NOTE that you will need to be concerned with the "char" array that that NO variable in the list also has the name of the array. Array char(*) $ this char another var; will generate an error of recursive name. So if &amp;amp;clist has Char then you get the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 22:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384454#M91882</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-31T22:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384461#M91883</link>
      <description>&lt;P&gt;This SQL block in your code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name, put(count(name),5.-L) into :clist separated by ' ' , :charct
from dictionary.columns
where libname=upcase("&amp;amp;lib") and memname=upcase("&amp;amp;mem") and type='char';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is probably trying to do what this code does more clearly and accurately. &amp;nbsp;Using the %UPCASE() macro funciton instead of the UPCASE() function will allow SAS to use the indexes for the LIBNAME and MEMNAME fields to avoid searching the metadata for all open libraries. &amp;nbsp;Using the automatic macro varaible SQLOBS to store the count will both eliminate any leading/trailing spaces and also accurately count when there are no character variables in the dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name
  into :clist separated by ' '
  from dictionary.columns
  where libname=%upcase("&amp;amp;lib")
    and memname=%upcase("&amp;amp;mem")
    and type='char'
;
%let charct=&amp;amp;sqlobs;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is not at all clear what the data step is trying to do. &amp;nbsp;It looks like you want to make a series of macro variables that contain the names of all of the character variables that are totally empty. &amp;nbsp;Why would you want that in a series of macro varibles instead of just in one macro variable, like you did in the first step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if the whole purpose is to get that list then you can &lt;STRONG&gt;skip the first step completely&lt;/STRONG&gt; and do the whole job in the single data step.&lt;/P&gt;
&lt;P&gt;Use the _CHARACTER_ variable list in the ARRAY definition to find all of the character variables. You will need to create a character variable that will be used to hold the generated list at the end so define it first, before the SET statement, and that way your array will always have at least one entry. &amp;nbsp;Make your flag variables numeric and temporary and then you can just used a fixed size for the array that is larger than anything you would ever see in a real dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  length _namelist_ $32767 ;
  set &amp;amp;mem end=done;
  array _char_ _character_ ;
  array _flag_ (8000) _temporary_ ;
  do i=2 to dim(_char_);
    if not missing(_char_(i))' then _flag_(i)=1;
  end;
  if done then do;
    do i=2 to dim(_char_);
      if _flag_(i) then _namelist_ = catx(' ',_namelist_,vname(_char_(i)));
    end;
    call symputx('emptyvars',_namelist_);
    call symputx('nempty',countw(_namelist_));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 22:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384461#M91883</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-31T22:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384462#M91884</link>
      <description>&lt;P&gt;You've already gotten an explanation of the easy parts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The missing piece ... this should probably work but you will have to test it because I'm not sure about some of the details ... is to swtich from PUT to PUTN. &amp;nbsp;The PUT function requires that you hard-code a format. &amp;nbsp;The PUTN function expects that the format will be an expression such as the variable named LEN.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While that may eliminate syntax errors, the end result is still somewhat far-fetched. &amp;nbsp;Why should the name of a macro variable depend on the length of a character variable in the data set? &amp;nbsp;What if you have two character variables with the same length? &amp;nbsp;You can't use a single macro variable to hold the names of both. &amp;nbsp;In short, eliminating syntax errors will not eliminate all the problems. &amp;nbsp;Start with planning what you would like the end result to be. &amp;nbsp;Then we can talk about how to program it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDITED:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps what you are looking to do is the opposite. &amp;nbsp;Store a macro variable where the name of the macro variable matches the name of the DATA step variable, and the value of the macro variable is the length of the DATA step variable. &amp;nbsp;That can be done:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call symputx(vname(char{i}), length(vname(char{i})));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By switching to SYMPUTX instead of SYMPUT, the value of the macro variable has all leading and trailing blanks removed automatically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it is much simpler to do that without so much macro language. &amp;nbsp;Create a data set (not a set of macro variables) from dictionary.columns. &amp;nbsp;For each observation in that data set, simply use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call symputx(name, length);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm pretty sure those are the right variable names from DICTIONARY.COLUMNS, but I would need to verify that.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 11:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/384462#M91884</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-01T11:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/385130#M92090</link>
      <description>&lt;P&gt;But I still don't understand what is the purpose for&amp;nbsp;using "&amp;nbsp;5. - L " ?&amp;nbsp; Where is Name from?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 21:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/385130#M92090</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-08-02T21:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/385135#M92092</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;But I still don't understand what is the purpose for&amp;nbsp;using "&amp;nbsp;5. - L " ?&amp;nbsp; Where is Name from?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So in your original code you had this line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select name, put(count(name),5.-L) into :clist separated by ' ' , :charct&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The 5. is the format and the -L is format modifier that says to Left align the value. So when the number being PUT() is less than 100,000 the spaces are at the end instead of the beginning. &amp;nbsp;The reason it was used was to a create macro variable that did not have spaces in the beginning. &amp;nbsp;As I said before that is not really how you should do this. &amp;nbsp;You could instead use the TRIMMED keyword.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select name, count(name)
  into :clist separated by ' ' , :charct trimmed&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or even better just use the automatic macro variable SQLOBS which will have the count.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select name  into :clist separated by ' '  .... ;
%let charct=&amp;amp;sqlobs;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Later in the program there appears to be another attempt to perhaps use the -L format modifier:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('var'||put(cnt, len-l),vname(char(i)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But that use is syntacticly incorrect. The PUT function wants a format &lt;SPAN&gt;specification&amp;nbsp;&lt;/SPAN&gt;, not an expression. Even if you change to the PUTN() function which takes the format specification from a character variable or expression you still wouldn't want to use the varaible LEN as it has no meaning. &amp;nbsp;You could just hard code it to something that is long enough for any possible value of CNT, like the 5. in the SQL statement.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('var'||put(cnt, 5.-L),vname(char(i)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you were trying to do this NOW you wouldn't use that syntax. &amp;nbsp;Use the CATS() function to append a numberic suffix onto a base name. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx(cats('var',cnt),vname(char(i)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you wanted a numeric suffix that was more than 12 digits long ( that is a number larger than 999,999,999,999) then you could use the PUT() or PUTN() function. &amp;nbsp;So since your prefix, VAR, is three characters long and a SAS name can only be 32 characters long so you could support a numeric suffix of up to 29 digits (if SAS could actually represent a number that large distinctly).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx(cats('var',put(cnt,29.)),vname(char(i)));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Aug 2017 22:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/385135#M92092</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-02T22:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error for length?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/386265#M92481</link>
      <description>&lt;P&gt;Thank you so much for everyone's comprehensive and thorough explanation, sharing your expert opinions.&amp;nbsp;&amp;nbsp; I am grateful for all of your heart-melted kindness help! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 13:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-Error-for-length/m-p/386265#M92481</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-08-08T13:59:00Z</dc:date>
    </item>
  </channel>
</rss>

