<?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: To transpose table but retain the column length accordingly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-transpose-table-but-retain-the-column-length-accordingly/m-p/413949#M101381</link>
    <description>&lt;P&gt;To what purpose, is this for reading data in from a text file, or altering an existing table?&amp;nbsp; The way to use it is slightly different depending on how you want to use it.&amp;nbsp; For instance, if it is to read a text file in, then you can use that dataset to generate the import code:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set have;
  by table_nm;
  if first.table_nm then do;
    call execute(cats('filename tmp "c:\',table_nm,'";'));
    call execute('data '||strip(table_nm)||'; file tmp; length...');
  end;
  else do;
     ...
  end;
run;&lt;/PRE&gt;
&lt;P&gt;If its to alter data already present then generate a proc datasets statment to alter.&amp;nbsp; This is where providing some test data (in the form of a datastep) and what the output should look like is so important, as I keep mentioning.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Nov 2017 10:09:30 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-11-16T10:09:30Z</dc:date>
    <item>
      <title>To transpose table but retain the column length accordingly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-transpose-table-but-retain-the-column-length-accordingly/m-p/413934#M101379</link>
      <description>&lt;P&gt;Hi SAS Community, Good day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table, which stores all columns attributes in row base, named as UDF_DEF table. In this table, it has column such as TABLE_NM, COLUMN_NM, COLUMN_DATA_TYPE, COLUMN_LENGTH.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the sample data in table A would look like this:&lt;/P&gt;&lt;PRE&gt;TABLE_NM, COLUMN_NM, COLUMN_DATA_TYPE, COLUMN_LENGTH.
A          AGE              NUM               8
A          SEX               CHAR            20
A          LOCATION        CHAR            300
B          CAR BRAND      CHAR            100
C          NEWS BODY     LNGCHAR          1000&lt;/PRE&gt;&lt;P&gt;Sorry for the text alignment, but basically thats the data of this table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, when i do a proc transpose to make each of the row in COLUMN_NM become 1 column each, new columns are all 1000 length due to the fact that 'COLUMN_NM' in table A is 1000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way that i could modify transpose function to give each of the columns a specific/individual length instead of the default 1000 ? What would the be method?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 09:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-transpose-table-but-retain-the-column-length-accordingly/m-p/413934#M101379</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2017-11-16T09:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: To transpose table but retain the column length accordingly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-transpose-table-but-retain-the-column-length-accordingly/m-p/413949#M101381</link>
      <description>&lt;P&gt;To what purpose, is this for reading data in from a text file, or altering an existing table?&amp;nbsp; The way to use it is slightly different depending on how you want to use it.&amp;nbsp; For instance, if it is to read a text file in, then you can use that dataset to generate the import code:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set have;
  by table_nm;
  if first.table_nm then do;
    call execute(cats('filename tmp "c:\',table_nm,'";'));
    call execute('data '||strip(table_nm)||'; file tmp; length...');
  end;
  else do;
     ...
  end;
run;&lt;/PRE&gt;
&lt;P&gt;If its to alter data already present then generate a proc datasets statment to alter.&amp;nbsp; This is where providing some test data (in the form of a datastep) and what the output should look like is so important, as I keep mentioning.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 10:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-transpose-table-but-retain-the-column-length-accordingly/m-p/413949#M101381</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-16T10:09:30Z</dc:date>
    </item>
  </channel>
</rss>

