<?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 modify length of a character variable without changing its column position? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812298#M320488</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/412505"&gt;@yellowyellowred&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, this changes its length but it doesn't change its format so my data still truncates.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The data is not truncated, only the number of chars you see is still limited. You can change that by using proc dataset and modify. Have a look at the docs for details.&lt;/P&gt;</description>
    <pubDate>Tue, 10 May 2022 06:19:20 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-05-10T06:19:20Z</dc:date>
    <item>
      <title>How to modify length of a character variable without changing its column position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812286#M320479</link>
      <description>&lt;P&gt;My code is:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data want;
length name $ 300;&lt;BR /&gt;format name $300.;
set have (obs=0);
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code takes in a data set "have" (which has a character variable "name" in it) and I want it instead to output only the column names of "have", with the new "name" variable having length 300. However, the output changes the column position of "name" and places it as the first column. How do I retain its column position.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 03:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812286#M320479</guid>
      <dc:creator>yellowyellowred</dc:creator>
      <dc:date>2022-05-10T03:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify length of a character variable without changing its column position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812294#M320484</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.class;
run;


proc sql;
alter table have
modify name char(400),sex char(200);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 May 2022 03:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812294#M320484</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-05-10T03:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify length of a character variable without changing its column position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812295#M320485</link>
      <description>&lt;P&gt;SAS creates variables in a data step during the compilation phase using the attributes from the first occurrence it encounters the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to maintain the variable order then you could do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length name $ 300;
set have (obs=0 keep=&amp;lt;var on pos 1&amp;gt; -- &amp;lt;var before name&amp;gt;);
length name $ 300;
set have (obs=0 keep=&amp;lt;var after name&amp;gt;--&amp;lt;last var&amp;gt;);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Same applies for any combination of tables: The variable definition will come from the first source table this variable exist in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Added later: Use the coding approach&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;proposes. It's cleaner.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 09:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812295#M320485</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-05-10T09:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify length of a character variable without changing its column position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812297#M320487</link>
      <description>&lt;P&gt;Hi, this changes its length but it doesn't change its format so my data still truncates.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 04:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812297#M320487</guid>
      <dc:creator>yellowyellowred</dc:creator>
      <dc:date>2022-05-10T04:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify length of a character variable without changing its column position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812298#M320488</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/412505"&gt;@yellowyellowred&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, this changes its length but it doesn't change its format so my data still truncates.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The data is not truncated, only the number of chars you see is still limited. You can change that by using proc dataset and modify. Have a look at the docs for details.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 06:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812298#M320488</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-05-10T06:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify length of a character variable without changing its column position?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812330#M320503</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.class;
run;


proc sql;
alter table have
modify name char(400) format=$400.,sex char(200)  format=$200.;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 May 2022 08:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-length-of-a-character-variable-without-changing/m-p/812330#M320503</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-05-10T08:56:16Z</dc:date>
    </item>
  </channel>
</rss>

