<?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: Shorting variable length in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108743#M30306</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is another try borrowing some ideas from Astounding's post:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;Quality_of_FASP__Family_Child_As=1;&lt;/P&gt;&lt;P&gt;Quality_of_FASP_arthurmikemarkks=2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table name as select distinct name from dictionary.columns where LIBNAME='WORK' AND MEMNAME='HAVE';QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data NAME;&lt;/P&gt;&lt;P&gt;set name;&lt;/P&gt;&lt;P&gt;do i=1 to countw(name,'_');&lt;/P&gt;&lt;P&gt;&amp;nbsp; b=scan(name,-i,'_');&lt;/P&gt;&lt;P&gt;&amp;nbsp; lc=lengthn(b)+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lt+lc;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if lt&amp;gt;=6 then leave;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt; new_name=substr(name,1,lengthn(name)-lt);&lt;/P&gt;&lt;P&gt; call missing(lt);&lt;/P&gt;&lt;P&gt; keep name new_name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select cats(name,'=',new_name) into :rename separated by ' ' from name;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;rename &amp;amp;rename;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Aug 2012 15:16:16 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-08-30T15:16:16Z</dc:date>
    <item>
      <title>Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108736#M30299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Arial;"&gt;Hi—&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;I need to shorten the length of a bunch of variables at once, over 100. Most of them at up to 32 &lt;/SPAN&gt;&lt;SPAN style="font-family: Arial;"&gt;characters&lt;/SPAN&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt; and I need to shorten them all by around 6 to 8 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial;"&gt;characters. &lt;/SPAN&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;So &lt;SPAN style="font-family: Arial;"&gt;variables &lt;/SPAN&gt;with a title like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Arial;"&gt;Quality_of_FASP__Family_Child_As&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Arial;"&gt;I need to shorten to this &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Arial;"&gt;Quality_of_FASP__Family_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Arial;"&gt;Any help is greatly aperciated. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Arial;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Arial;"&gt;Thanks! &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 13:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108736#M30299</guid>
      <dc:creator>RobertNYC</dc:creator>
      <dc:date>2012-08-30T13:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108737#M30300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you want to specify the new names or jjust cut the old names off at X characters?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 13:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108737#M30300</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-30T13:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108738#M30301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cut off at X charters. Thanks!&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 13:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108738#M30301</guid>
      <dc:creator>RobertNYC</dc:creator>
      <dc:date>2012-08-30T13:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108739#M30302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, what if you have extreme long tailing character , such as &lt;SPAN style="font-size: 10.0pt; font-family: Arial;"&gt;Quality_of_FASP__Family_arthurtabachneckhaikuobian, will you cut it even it is more than 8 characters?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here is an your liberal approach, the conservative one can easily tweaked to:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Arial;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;a='Quality_of_FASP__Family_Child_As';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;do i=1 to countw(a,'_');&lt;/P&gt;&lt;P&gt;&amp;nbsp; b=scan(a,-i,'_');&lt;/P&gt;&lt;P&gt;&amp;nbsp; lc=lengthn(b)+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lt+lc;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if lt&amp;gt;=6 then leave;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt; new_a=substr(a,1,lengthn(a)-lt);&lt;/P&gt;&lt;P&gt; call missing(lt);&lt;/P&gt;&lt;P&gt; keep a new_a;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 14:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108739#M30302</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-30T14:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108740#M30303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Hai. kuo. Its not exatlly wat I am looking for though. I'm looking to shorten the actually variable &lt;SPAN style="text-decoration: underline;"&gt;names&lt;/SPAN&gt; not the cell contents. Do you know how to do that? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 14:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108740#M30303</guid>
      <dc:creator>RobertNYC</dc:creator>
      <dc:date>2012-08-30T14:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108741#M30304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can pick the length by altering the 3rd parameter within SUBSTR.&amp;nbsp; Of course you have to adjust WORK and HAVE to reflect your data:&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 name || '=' || substr(name,1,25) into : rename_list separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from dictionary.columns where libname='WORK' and memname='HAVE';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets library=work;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; modify have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; rename &amp;amp;rename_list;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 14:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108741#M30304</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-08-30T14:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108742#M30305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Whoops, needs to be modified.&amp;nbsp; This will generate errors for any names not being truncated.&amp;nbsp; Add to the WHERE clause:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where libname='WORK' and memname='HAVE' and length(name) &amp;gt; 25;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry about that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 14:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108742#M30305</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-08-30T14:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108743#M30306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is another try borrowing some ideas from Astounding's post:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;Quality_of_FASP__Family_Child_As=1;&lt;/P&gt;&lt;P&gt;Quality_of_FASP_arthurmikemarkks=2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table name as select distinct name from dictionary.columns where LIBNAME='WORK' AND MEMNAME='HAVE';QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data NAME;&lt;/P&gt;&lt;P&gt;set name;&lt;/P&gt;&lt;P&gt;do i=1 to countw(name,'_');&lt;/P&gt;&lt;P&gt;&amp;nbsp; b=scan(name,-i,'_');&lt;/P&gt;&lt;P&gt;&amp;nbsp; lc=lengthn(b)+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lt+lc;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if lt&amp;gt;=6 then leave;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt; new_name=substr(name,1,lengthn(name)-lt);&lt;/P&gt;&lt;P&gt; call missing(lt);&lt;/P&gt;&lt;P&gt; keep name new_name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select cats(name,'=',new_name) into :rename separated by ' ' from name;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;rename &amp;amp;rename;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 15:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108743#M30306</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-30T15:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108744#M30307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might have a better result if you create a table of old an new names.&amp;nbsp; Instead of just truncating you could abbreviate words like "Quality" to "Qua" perhaps and Family.&amp;nbsp; Remove double underscores etc.&amp;nbsp; Then you can use that data set to gen a rename statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course you could do all the transformations to new names with SAS code PRX or TRNSTRN etc. but it might be just as easy to do it by hand.&amp;nbsp; You will only need it once. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 15:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108744#M30307</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-08-30T15:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108745#M30308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P style="font-style: inherit; font-family: inherit;"&gt;Whoops, needs to be modified.&amp;nbsp; This will generate errors for any names not being truncated.&amp;nbsp; Add to the WHERE clause:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P style="font-style: inherit; font-family: inherit;"&gt;where libname='WORK' and memname='HAVE' and length(name) &amp;gt; 25;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P style="font-style: inherit; font-family: inherit;"&gt;Sorry about that&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or simply replace the SUBSTR function with the less used SUBSTRN function which won't generate any errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More on SUBSTRN here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002255112.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002255112.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002255112.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers from Portugal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 16:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108745#M30308</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2012-08-30T16:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108746#M30309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry, the issue is a little different.&amp;nbsp; I don't think SUBSTRN can solve it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within dictionary.columns, NAME has a length of 32 (although there may be trailing blanks).&amp;nbsp; There are always enough characters to read.&amp;nbsp; The problem comes about if the program were to generate this sort of statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rename whoops=whoops;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In that case, PROC DATASETS generates an error because the name whoops is already being used.&amp;nbsp; Maybe it should be this way, maybe not, but that's the result I'm getting.&amp;nbsp; I'm using 9.1 so perhaps things have changed in more up-to-date releases.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 16:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108746#M30309</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-08-30T16:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108747#M30310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm. OK, didn't saw that. You're absolutely right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My mistake, sorry. SUBSTRN won't help there, and it's actually not needed, as I was forgetting the sufficient length of the INPUT var.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers from Portugal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 16:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108747#M30310</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2012-08-30T16:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108748#M30311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is not pretty but it works. I am a sucker for itterative macro loops. The new dataset will be the old dataset's name with an "s_" prefix in the work library. the function %shortnam() takes the first argument as the length for substrn() the second argument is the lib name the third is the data set name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*--BE SURE TO USE CAPITALS I DID NOT BOTHER WITH AN UPCASE FUNCTION*/&lt;/P&gt;&lt;P&gt;/*------------------------------------------------------------------------------------------*/&lt;/P&gt;&lt;P&gt;option symbolgen mlogic mprint;&lt;/P&gt;&lt;P&gt;%macro shortname(length,libname,dsn);&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select count(*) into :tempcnt from dictionary.columns where libname="&amp;amp;libname" and memname="&amp;amp;dsn";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let varcnt=%sysfunc(compress(&amp;amp;tempcnt)); /*there might be a better way to do this*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select name into :name_1-:name_&amp;amp;varcnt from dictionary.columns where libname="&amp;amp;libname" and memname="&amp;amp;dsn";&lt;/P&gt;&lt;P&gt;select substrn(name,1,&amp;amp;length) into :s_name_1-:s_name_&amp;amp;varcnt from dictionary.columns where libname="&amp;amp;libname" and memname="&amp;amp;dsn";&lt;/P&gt;&lt;P&gt;select compress(format,'CHAR') into :format_1-:format_&amp;amp;varcnt from dictionary.columns where libname="&amp;amp;libname" and memname="&amp;amp;dsn";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data s_&amp;amp;dsn (keep= %do i=1 %to &amp;amp;varcnt; &amp;amp;&amp;amp;s_name_&amp;amp;i %end;);&lt;/P&gt;&lt;P&gt;set &amp;amp;libname..&amp;amp;dsn;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;varcnt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;format &amp;amp;&amp;amp;s_name_&amp;amp;i &amp;amp;&amp;amp;format_&amp;amp;i;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;&amp;amp;s_name_&amp;amp;i=&amp;amp;&amp;amp;name_&amp;amp;i ;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend shortname;&lt;/P&gt;&lt;P&gt;%shortname(6,MYLIB,EGYPT_201107_201207)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 19:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108748#M30311</guid>
      <dc:creator>johns576</dc:creator>
      <dc:date>2012-08-30T19:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108749#M30312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John, good point, but not a very performance wise solution.&lt;/P&gt;&lt;P&gt;Your code implies duplicating columns and rewriting the &lt;SPAN style="text-decoration: underline;"&gt;whole&lt;/SPAN&gt; dataset.&lt;/P&gt;&lt;P&gt;Astounding solution uses dataset procedure which only reads/writes the descriptor portion of the dataset.&lt;/P&gt;&lt;P&gt;I really think that's the best solution you can have. Short code and effective.&lt;/P&gt;&lt;P&gt;No need to rewrite the whole data portion of the file when you just want to edit the metadata of the table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers from Portugal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2012 07:57:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108749#M30312</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2012-08-31T07:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Shorting variable length</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108750#M30313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One additional issue to think about:&amp;nbsp; what happens if two variable names get shortened, and become identical as a result?&amp;nbsp; The results vary, depending on the methods you choose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2012 14:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Shorting-variable-length/m-p/108750#M30313</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-08-31T14:18:41Z</dc:date>
    </item>
  </channel>
</rss>

