<?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: Character variable with dynamic length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113573#M23411</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;YES.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 May 2012 10:14:45 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2012-05-15T10:14:45Z</dc:date>
    <item>
      <title>Character variable with dynamic length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113566#M23404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the discussion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Combining the same variable on different records into a single variable&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you all had given some wonderful suggestions. i went ahead and used LinLin's suggestion. I had the following requirement added.&lt;/P&gt;&lt;P&gt; &lt;BR /&gt;I had one additional question. Can we have newline to be dynamic?&lt;/P&gt;&lt;P&gt; &lt;BR /&gt;As in if we do not know the maximum number of rows that can have the same id. Does SAS support dynamic variables.&lt;/P&gt;&lt;P&gt; &lt;BR /&gt;We have scenarios where newline can be 100, 350 or 500 and could be even more.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 13:44:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113566#M23404</guid>
      <dc:creator>kdm</dc:creator>
      <dc:date>2012-05-14T13:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Character variable with dynamic length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113567#M23405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS does not support dynamic variable lengths.&amp;nbsp; You can obtain the same result as dynamic variables by passing the data once to obtain the maximum number of repeats for the newline variable and then using macro programming to set the length for the subsequent step.&amp;nbsp; The downside is that you have to read the data twice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 14:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113567#M23405</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2012-05-14T14:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Character variable with dynamic length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113568#M23406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Doc,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you provide me with an example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kurian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 15:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113568#M23406</guid>
      <dc:creator>kdm</dc:creator>
      <dc:date>2012-05-14T15:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Character variable with dynamic length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113569#M23407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can creates a dataset with id as the variable , then I can do a count on the maximum occurrence of an id. Once I get this count can I declare the length variable with this count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example the max occurrence of an id is 5 and this is stored in countid. Suppose the lenth of the line variable is 50 then new line will be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length newline $countid;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this feasible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 15:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113569#M23407</guid>
      <dc:creator>kdm</dc:creator>
      <dc:date>2012-05-14T15:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Character variable with dynamic length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113570#M23408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;then the length should be 5*50=250;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can try something like the code below:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id line$ 50.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;100&amp;nbsp; abcdefghijkollldsdksjd&lt;/P&gt;&lt;P&gt;100 djsjdklsjdksdlsldklskdsld&lt;/P&gt;&lt;P&gt;100 djskdjsldjlsdjlsdjlsdljskdjskdjskdioeioeoeoe&lt;/P&gt;&lt;P&gt;100 jksldksldklsldklsdksldksldklskdls&lt;/P&gt;&lt;P&gt;100 djsldksldksldklsdkdadskldkasldklsdksdklskdsk&lt;/P&gt;&lt;P&gt;200 djksldklskdlskdls&lt;/P&gt;&lt;P&gt;200 uuuuuuuuuuuuuuuuuu&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select max(count)*50 into :countid separated by ' ' from (select count(id) as count from have group by id);&lt;/P&gt;&lt;P&gt; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(keep=id newline);&lt;/P&gt;&lt;P&gt;length newline $&amp;amp;countid;&lt;/P&gt;&lt;P&gt;retain newline;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by id ;&lt;/P&gt;&lt;P&gt;newline=cats(newline,line);&lt;/P&gt;&lt;P&gt;if last.id then do;output ;&lt;/P&gt;&lt;P&gt;call missing(newline); end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc contents;run;&lt;/P&gt;&lt;P&gt;Message was edited by: Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 15:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113570#M23408</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-05-14T15:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Character variable with dynamic length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113571#M23409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can set it with the maximum length .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length newline $ 32767 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if the length can't still hold all of the value, then I think you need two or more newline to hold .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 04:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113571#M23409</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-05-15T04:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Character variable with dynamic length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113572#M23410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What if the countid in linlin's example exceeds 32767, will the record get truncated?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kurian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 08:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113572#M23410</guid>
      <dc:creator>kdm</dc:creator>
      <dc:date>2012-05-15T08:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Character variable with dynamic length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113573#M23411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;YES.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 10:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-variable-with-dynamic-length/m-p/113573#M23411</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-05-15T10:14:45Z</dc:date>
    </item>
  </channel>
</rss>

