<?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: how to assign max length of  record value to the  variable length in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-assign-max-length-of-record-value-to-the-variable-length/m-p/602488#M16821</link>
    <description>&lt;P&gt;Why a macro? What are you trying to do overall? What have you tried so far?&lt;BR /&gt;&lt;BR /&gt;If you want to find the maximum of a numeric value you can use PROC MEANS or any data step or SQL. Depending on what you want to do afterwards will define which is the best approach. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;EDIT: FYI - I moved your question from the developer community to the SAS New Users which seems more appropriate based on your question.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278637"&gt;@varam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have data like this:&lt;/P&gt;
&lt;P&gt;Race&amp;nbsp;&lt;/P&gt;
&lt;P&gt;white&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;American&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;/P&gt;
&lt;P&gt;black or white&amp;nbsp; 14&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;that digits are the length of each record&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to assign max length of the record to the variable length by using a macro, please tell the logic how to solve&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2019 16:58:25 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-11-07T16:58:25Z</dc:date>
    <item>
      <title>how to assign max length of  record value to the  variable length</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-assign-max-length-of-record-value-to-the-variable-length/m-p/602487#M16820</link>
      <description>&lt;P&gt;I have data like this:&lt;/P&gt;&lt;P&gt;Race&amp;nbsp;&lt;/P&gt;&lt;P&gt;white&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;American&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;/P&gt;&lt;P&gt;black or white&amp;nbsp; 14&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that digits are the length of each record&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to assign max length of the record to the variable length by using a macro, please tell the logic how to solve&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 16:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-assign-max-length-of-record-value-to-the-variable-length/m-p/602487#M16820</guid>
      <dc:creator>varam</dc:creator>
      <dc:date>2019-11-07T16:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign max length of  record value to the  variable length</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-assign-max-length-of-record-value-to-the-variable-length/m-p/602488#M16821</link>
      <description>&lt;P&gt;Why a macro? What are you trying to do overall? What have you tried so far?&lt;BR /&gt;&lt;BR /&gt;If you want to find the maximum of a numeric value you can use PROC MEANS or any data step or SQL. Depending on what you want to do afterwards will define which is the best approach. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;EDIT: FYI - I moved your question from the developer community to the SAS New Users which seems more appropriate based on your question.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278637"&gt;@varam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have data like this:&lt;/P&gt;
&lt;P&gt;Race&amp;nbsp;&lt;/P&gt;
&lt;P&gt;white&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;American&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;/P&gt;
&lt;P&gt;black or white&amp;nbsp; 14&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;that digits are the length of each record&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to assign max length of the record to the variable length by using a macro, please tell the logic how to solve&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 16:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-assign-max-length-of-record-value-to-the-variable-length/m-p/602488#M16821</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-07T16:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign max length of  record value to the  variable length</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-assign-max-length-of-record-value-to-the-variable-length/m-p/603095#M16899</link>
      <description>&lt;P&gt;Best is to know your data and define variables based on this knowledge (like a pre-defined data dictionary).&lt;/P&gt;
&lt;P&gt;If I understand your question then below code for what you've been asking for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input myvar $50.;
  datalines;
white
American
black or white
;

proc sql noprint;
  select max(lengthn(myvar)) into :myvar_max_len trimmed
  from have
  ;
quit;
%put &amp;amp;=myvar_max_len;


data want;
  length myvar $ &amp;amp;myvar_max_len;
  set have(rename=(myvar=_myvar));
  myvar=_myvar;
  drop _myvar;
run;

proc contents data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you just want to reduce the variable length to save storage space then consider using option &lt;EM&gt;compress=yes&lt;/EM&gt; as this will compress blanks when storing a SAS table on disk.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 23:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-assign-max-length-of-record-value-to-the-variable-length/m-p/603095#M16899</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-11-10T23:06:50Z</dc:date>
    </item>
  </channel>
</rss>

