<?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: setting length of character variables without changing order in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703288#M25998</link>
    <description>yes</description>
    <pubDate>Thu, 03 Dec 2020 07:22:50 GMT</pubDate>
    <dc:creator>archita</dc:creator>
    <dc:date>2020-12-03T07:22:50Z</dc:date>
    <item>
      <title>setting length of character variables without changing order</title>
      <link>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703275#M25994</link>
      <description>&lt;P&gt;i have a dataset with more than 100 variables , I want to set the length of all character variables without changing their order. how to get this ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 07:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703275#M25994</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2020-12-03T07:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: setting length of character variables without changing order</title>
      <link>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703276#M25995</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130051"&gt;@archita&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i have a dataset with more than 100 variables , I want to set the length of all character variables without changing their order. how to get this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you want to change all variable to have the same length?&lt;/P&gt;
&lt;P&gt;Do you know how to change the length of one variable?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 07:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703276#M25995</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-12-03T07:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: setting length of character variables without changing order</title>
      <link>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703281#M25996</link>
      <description>&lt;P&gt;Should all character variables have the same length?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 07:10:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703281#M25996</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-12-03T07:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: setting length of character variables without changing order</title>
      <link>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703284#M25997</link>
      <description>i want to change all the variable to same length without changong their order</description>
      <pubDate>Thu, 03 Dec 2020 07:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703284#M25997</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2020-12-03T07:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: setting length of character variables without changing order</title>
      <link>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703288#M25998</link>
      <description>yes</description>
      <pubDate>Thu, 03 Dec 2020 07:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703288#M25998</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2020-12-03T07:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: setting length of character variables without changing order</title>
      <link>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703290#M25999</link>
      <description>&lt;P&gt;proc sql seems to be a good choice to solve the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create a dataset that can be modified */
data work.class;
   set sashelp.class;
run;

/* the view will contain all char-variables ordered by their appearance in the dataset */
proc sql noprint;
   create view work.vars as
      select Name
         from sashelp.vcolumn
            where Libname = 'WORK'
               and MemName = 'CLASS'
               and Type = 'char'
         order by Varnum
   ;
quit;

/* creates and executes a proc-sql-step setting the length of all char-variables to 42 - the generated code is written to the log */
data _null_;
   set work.vars end= jobDone;

   if _n_ = 1 then do;
      call execute('proc sql noprint;');
      call execute('alter table work.class');
      call execute('modify ');
   end;
   
   call execute(catx(' ', Name, 'char(42)', ifc(not JobDone, ',', '')));

   if jobDone then do;
      call execute('; quit;');
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Dec 2020 07:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703290#M25999</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-12-03T07:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: setting length of character variables without changing order</title>
      <link>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703300#M26001</link>
      <description>I need it only by data step.</description>
      <pubDate>Thu, 03 Dec 2020 08:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703300#M26001</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2020-12-03T08:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: setting length of character variables without changing order</title>
      <link>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703304#M26003</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130051"&gt;@archita&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I need it only by data step.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is similar to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;'s approach:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call execute('data have; length');
do until(last);
  set sashelp.vcolumn end=last;
  where libname='WORK' &amp;amp; memname='HAVE';
  call execute(catx(' ',name,ifc(type='char','$42',put(length,1.))));
end;
call execute('; set have; run;');
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Dec 2020 09:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/setting-length-of-character-variables-without-changing-order/m-p/703304#M26003</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-12-03T09:09:52Z</dc:date>
    </item>
  </channel>
</rss>

