<?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 change a variable's length without change the position in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112904#M31269</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@PGStats: Is there a way to do that, as you have shown, without modifying the original table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 May 2012 22:34:25 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-05-11T22:34:25Z</dc:date>
    <item>
      <title>How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112899#M31264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How to change a variable's length without change its position? Is there any simple way?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*Here is just an example I use sashelp.class,in fact my dataset has hundreds of variables.the varialbe which I want to change the length locates in the middle.*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* In the example below,I don't want to change SEX's position(second postion)*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;length SEX $15.;&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;SEX='Testing 12345';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 19:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112899#M31264</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-05-11T19:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112900#M31265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think there is any neat way. Here is a half-baked solution (ab)using proc sql -- I would appreciate any corrections or modifications. Thanks for the interesting question!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Consolas; font-size: 90%; line-height: 1.1;"&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000;"&gt;/* lengthen sex to $15 without changing the varnum.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NOTE: This will bomb when the var Sex is the first or the last var. */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;create&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;view&lt;/SPAN&gt;&lt;SPAN&gt; cols &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;select&lt;/SPAN&gt;&lt;SPAN&gt; name, varnum &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; dictionary.columns &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;where&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;libname&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;"SASHELP"&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;and&lt;/SPAN&gt;&lt;SPAN&gt; memname = &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;"CLASS"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;select&lt;/SPAN&gt;&lt;SPAN&gt; varnum &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;into&lt;/SPAN&gt;&lt;SPAN&gt; :sexNum &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; cols &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;where&lt;/SPAN&gt;&lt;SPAN&gt; name = &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;"Sex"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;select&lt;/SPAN&gt;&lt;SPAN&gt; name &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;into&lt;/SPAN&gt;&lt;SPAN&gt; :before separated &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;by&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;", "&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; cols &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;where&lt;/SPAN&gt;&lt;SPAN&gt; varnum &amp;lt; &amp;amp;sexNum;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;select&lt;/SPAN&gt;&lt;SPAN&gt; name &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;into&lt;/SPAN&gt;&lt;SPAN&gt; :after separated &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;by&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;", "&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; cols &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;where&lt;/SPAN&gt;&lt;SPAN&gt; varnum &amp;gt; &amp;amp;sexNum;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;create&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;table&lt;/SPAN&gt;&lt;SPAN&gt; class &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;as&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;select&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;before, "Testing 12345" as Sex length=&lt;/SPAN&gt;&lt;SPAN style="color: #008080;"&gt;&lt;STRONG&gt;15&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;, &amp;amp;after&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; sashelp.class;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000;"&gt;/* check */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;STRONG&gt;contents&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;=class &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;varnum&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000;"&gt;/* on lst -- in part&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Variables in Creation Order&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp;&amp;nbsp; Variable&amp;nbsp;&amp;nbsp;&amp;nbsp; Type&amp;nbsp;&amp;nbsp;&amp;nbsp; Len&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Char&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; Sex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Char&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; Age&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Num&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; Height&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Num&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; Weight&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Num&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&amp;nbsp; */&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 20:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112900#M31265</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2012-05-11T20:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112901#M31266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To change the length,we must use the LENGTH statement as the very first statement in the DATA STEP ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT&amp;nbsp; the position will be changed at the same time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you chang_y_chung.your method works well ,let's wait for somebody have a more simple method.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 21:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112901#M31266</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-05-11T21:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112902#M31267</link>
      <description>&lt;P&gt;&lt;EM&gt;Editor's Note: This is a popular topic.&amp;nbsp; Thanks also to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats﻿&lt;/a&gt;&amp;nbsp;and others for their contributions.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depends upon what you call simple.&amp;nbsp; How about:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select name
    into :names
      separated by " "
        from dictionary.columns
          where libname="SASHELP" and
            memname="CLASS"
  ;
quit;

data one;
 retain &amp;amp;names.; 
 length SEX $15.;
 set sashelp.class;
 SEX='Testing 12345';
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2016 16:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112902#M31267</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2016-09-28T16:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112903#M31268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Simpler :&lt;/P&gt;&lt;P&gt; &lt;BR /&gt;data test;&lt;BR /&gt;a = 1; b = "some text"; c = 3;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;alter table test modify b character(12);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 22:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112903#M31268</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-05-11T22:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112904#M31269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@PGStats: Is there a way to do that, as you have shown, without modifying the original table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 22:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112904#M31269</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-05-11T22:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112905#M31270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well I guess if you don't want to modify the original table, you must make a copy. I don't see how this could be done dynamically (with a view) without naming all the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;a = 1; b = "some text"; c = 3;&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 myTest as select * from test;&lt;/P&gt;&lt;P&gt;alter table myTest modify b character(12);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 23:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112905#M31270</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-05-11T23:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112906#M31271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That would definitely work.&amp;nbsp; Now the question is which is more efficient: using dictionary.columns or creating and modifying a table using the alter statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Interesting question!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 23:27:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112906#M31271</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-05-11T23:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112907#M31272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting indeed. It all depends on which efficiency matters most in a given circumstance. For a one shot deal, involving a moderate size table, the ALTER TABLE is quite efficient (maximizing coder efficiency). For greater data volume or frequency, I believe (in principle, not tested) the most efficient approach would be to create a SQL view like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;a = 1; b = "some text"; c = 3; d = "To be truncated";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data newLength;&lt;BR /&gt;input name :$UPCASE32. newLength;&lt;BR /&gt;datalines;&lt;BR /&gt;b 15&lt;BR /&gt;d 10&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;&amp;nbsp; select case when missing(newLength) then d.name else catt(d.name, " length=", newLength) end&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :names&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; separated by ","&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.columns as d left join newLength&amp;nbsp; as n &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on upcase(d.name)=n.name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname="WORK" and&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; memname="TEST"&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;&amp;nbsp; create view myTest as&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select &amp;amp;names. from test; &lt;BR /&gt;&amp;nbsp; drop table newLength;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could use that view to subset a large remote table in a very efficient way (maximizing machine efficiency).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 May 2012 02:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112907#M31272</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-05-12T02:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112908#M31273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could query the metadata and generate the code you need.&lt;/P&gt;&lt;P&gt;One method might be to generate a RETAIN statement (to set the order) only replacing the variable name that is changing length with a dummy name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select varnum,case when (upcase(name)='SEX') then '_X_' else name end&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; into :dummy, :varlist separated by ' '&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; from dictionary.columns&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; where libname='SASHELP' and memname='CLASS'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; order by varnum&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; retain &amp;amp;varlist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set sashelp.class ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length _x_ $20;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; _x_=sex;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; drop sex;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; rename _x_=sex;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 May 2012 14:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112908#M31273</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-05-12T14:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112909#M31274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table one as select * from sashelp.class;&lt;/P&gt;&lt;P&gt;alter table one modify sex character(20);&lt;/P&gt;&lt;P&gt;update one set sex='Testing 12345';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 May 2012 15:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112909#M31274</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-05-12T15:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112910#M31275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe this is too basic, but here's an arguably simpler method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1) note up to 4 variable names: first, prior, next, and last variables, &lt;/P&gt;&lt;P&gt;(2) split the data set at the item to be changed. &lt;BR /&gt;(3) restore the full data set by remerging the two halves on a shared unique record ID based on _N_.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA oneA (KEEP=uniquerec&amp;nbsp; name/*--priorvariable*/&amp;nbsp;&amp;nbsp;&amp;nbsp; sexB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oneB (KEEP=uniquerec&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; age--weight ) ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*1st( to n-1th)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nth&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n+1th--last&amp;nbsp; ... where n=position of var. to be changed */&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; SET sashelp.class; &lt;BR /&gt;LENGTH sexB $15.;&amp;nbsp;&amp;nbsp;&amp;nbsp; *sexB: will be longer version of variable sex; &lt;/P&gt;&lt;P&gt;sexB=sex;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *populate longer sexb with original sex values; &lt;/P&gt;&lt;P&gt;uniquerec = _N_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA newclass (DROP=uniquerec);&lt;/P&gt;&lt;P&gt;&amp;nbsp; MERGE oneA oneB;&amp;nbsp; BY uniquerec;&lt;/P&gt;&lt;P&gt;RENAME sexB=sex;&lt;/P&gt;&lt;P&gt;RUN;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *Viola?&amp;nbsp; &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More changed variables just require more "splits" of the data to contiguous chunks oneC, oneD, etc., followed by their re-merge on uniquerec.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jun 2014 21:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112910#M31275</guid>
      <dc:creator>thomasn</dc:creator>
      <dc:date>2014-06-30T21:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112911#M31276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually you have made it much more complex than it needs to be.&amp;nbsp; You just need to know the name of the variable you want to change and the name of the LAST variable in the data set.&amp;nbsp; You can get that by querying the output of PROC CONTENTS or DICTIONARY.COLUMNS (or sashelp.vcolumn).&amp;nbsp; So for example to change the length of the AGE variable in SASHELP.CLASS you could do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; var=AGE ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; lastvar = WEIGHT ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sashelp.class(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; = &amp;amp;var -- &amp;amp;lastvar) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;var &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sashelp.class ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;compare&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;=sashelp.class &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;compare&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;=want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Note that the same syntax will also work if the variable is the FIRST variable in input data set.&amp;nbsp; In that case the first SET statement will read 0 variables from the source.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; var=NAME ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; lastvar = WEIGHT ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sashelp.class(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; = &amp;amp;var -- &amp;amp;lastvar) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;var $&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;30&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sashelp.class ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;compare&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;=sashelp.class &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;compare&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;=want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jun 2014 22:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112911#M31276</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-06-30T22:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112912#M31277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are several statements as starting situation.&lt;/P&gt;&lt;P&gt;1/ it is not possible to change a variable length (char type) without the need to change the physical storage. This is due to the relation dbms row design.&lt;/P&gt;&lt;P&gt;2/ SAS did a redesign changing the physical order segregating char and number types when going from 8 to 9.&lt;/P&gt;&lt;P&gt;3/ SAS did not implement any interface for maintaining a physical order better to say the view to that physical order as of the V9 version is using that. It could be an easy enhancement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not see the need for the question of ordering variables in a physical or derer as that does not exist with the rdbms world. I assume it is some ease of coding. Would be better to go for good coding practices.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 06:09:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112912#M31277</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-07-01T06:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112913#M31278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1- Yes. That is why it is hard.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2- What are you talking about?&amp;nbsp; I couldn't care a wit whether SAS wants to STORE the data in the physical file in what ever order it wants as long as it understands the logical order for them so that it can present them back to me when I run a PROC PRINT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3- Again what are you talking about? SAS rules for order of variables in a table is the same as it has ever been.&amp;nbsp; The order is defined by the order that the compiler sees the fields being defined.&amp;nbsp; So if you write DATA NEW; SET OLD: RUN: then all of the variable in NEW will be defined in the same order as they were in OLD.&amp;nbsp; or if you write DATA NEW; format vist_date date9. ; set old; run; now the variable VISIT_DATE is the first variable in the table NEW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The question of the ORDERING of variables can be very critical to the ability to easily use a database. It is extremely annoying to browse the data and not see the key variables in the front. Or worse have a bunch of totally empty LOOONG character variables at the front so that you have to wade through screens of gibberish to figure out what you are looking at. Or to have the data fields appear in jumbled order.&amp;nbsp; Your doctor will be very confused if place DIASTOLIC before SYSTOLIC instead of the reverse as is normally used when reporting blood pressure readings.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 06:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112913#M31278</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-01T06:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112914#M31279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike,&lt;/P&gt;&lt;P&gt;In the past, I've solved problems similar to yours using an Attribute statement prior to the set statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data want.......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; attrib firstvar.........&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; secondvar......&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thirdvar.........&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sex....length=$15.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fourthvar......;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 11:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112914#M31279</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-07-01T11:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112915#M31280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P&gt;/2 you do not care but SAS techies are. They changed the order for the mentioned reason. For compatibility&amp;nbsp; they had to implement an order translation table.&lt;/P&gt;&lt;P&gt;When you could influence that ordering by that transaction table a lot of people could do easy coding with sas datasets&lt;/P&gt;&lt;P&gt;1/ with a column based dbms changing columns is easy but add in rows not.&lt;/P&gt;&lt;P&gt;3/ see the physical reordering as change it is not the same as in the old days,&lt;/P&gt;&lt;P&gt;4/ that is the reason to code the order and not being dependent of some other. With an external dbms using sql that lazy approach common to sas is not acceptable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 11:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112915#M31280</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-07-01T11:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112916#M31281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not to beat on you personally but I would like to emphasize that one of SAS's big strengths is how quickly you can use it to do analysis. What to find the means of all numeric variables in a table, but not sure how to spell every variables name? No problem. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL based DBMS systems that cannot handle combining tables where the variables are the same but the column order is different are not user friendly.&lt;/P&gt;&lt;P&gt;It is the DBMS language implementation team being lazy not the users who do not want to have to write out every variable name.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With SAS I can control the order of the variable in a dataset if I want to and still have the flexibility to override that order if I need to.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similarly where is the support in those languages/systems for user friendly things like variable lists (VAR1- VAR2,&amp;nbsp; NAME -- WEIGHT,&amp;nbsp; ADDRESS: ) .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 12:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112916#M31281</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-01T12:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112917#M31282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok Tom,&amp;nbsp; I agree with the strengths of sas language for analytics. &lt;/P&gt;&lt;P&gt;Influencing the order of variables on those sas datasets could be an easy to implement enhancement for SAS. Really getting control on the order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some reason SAS is not seeing their own strength,&amp;nbsp; their focus is moving to in database processing and sql interfaces. With those sql interfaces hitting all those incompatible sql implementations. I am no a fan of sql for analytics purposes as you are also not I see.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 13:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112917#M31282</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-07-01T13:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a variable's length without change the position</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112918#M31283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to pop my 2p's worth in, I agree with both arguments here.&amp;nbsp; Its not the DBMS developers who were being lazy, you should know what data you are dealing explicitly inside out, therefore being strict about specifying variable names shouldn't be a problem, Toad for instance has an object inspector where you can drag from a contents directly into code, so saving the typing (and the fact that SAS doesn't have this is a real annoyance).&amp;nbsp; The select * syntax for instance, whilst we are all guilty of using it, is the lazy approach, first you are selecting everything even though you may not necessarily need it, and within say&amp;nbsp; macro's could lead to some interesting outcomes.&lt;/P&gt;&lt;P&gt;I also agree that SQL lacking the lists is rather a nuisance however this is down to the concept behind the languages.&amp;nbsp; SQL works on normalized tables, and hence there's really no need to consider long lists of variables as these would be rows. &lt;/P&gt;&lt;P&gt;For my side, I program backwards from a spec, so the spec would be the main item to build, then from that you would order your select, fix lengths etc. then decide where that data came from etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example:&lt;/P&gt;&lt;P&gt;In study A I have four columns:&lt;/P&gt;&lt;P&gt;Parameter&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result1-result3 (these being lower, upper, mean)&lt;/P&gt;&lt;P&gt;I write a bit of code&amp;nbsp; &lt;/P&gt;&lt;P&gt;... select * from ... and process then output result3 to mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In study B I have the same thing, but they have cunningly moved mean between lower and upper:&lt;/P&gt;&lt;P&gt;I copy my code over and get and incorrect result.&amp;nbsp; The same thing, but explicitly stating variables would work in both instances:&lt;/P&gt;&lt;P&gt;Paramter lower mean upper:&lt;/P&gt;&lt;P&gt;... select parameter,mean from ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(ok, not the best example).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 13:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-change-a-variable-s-length-without-change-the-position/m-p/112918#M31283</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-01T13:26:21Z</dc:date>
    </item>
  </channel>
</rss>

