<?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: move data from columns to the left in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828595#M327311</link>
    <description>thank you so much</description>
    <pubDate>Sun, 14 Aug 2022 00:46:33 GMT</pubDate>
    <dc:creator>arde</dc:creator>
    <dc:date>2022-08-14T00:46:33Z</dc:date>
    <item>
      <title>How to: move data from columns to the left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828572#M327293</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would anyone know how to move data in columns to the left so that there's no missing cells in between them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;have:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 480pt;" border="0" width="640" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;Title&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column1&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column2&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column3&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column4&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column5&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column6&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column7&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column8&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Colors1&lt;/TD&gt;
&lt;TD&gt;Red&lt;/TD&gt;
&lt;TD&gt;Blue&lt;/TD&gt;
&lt;TD&gt;Black&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Yellow&lt;/TD&gt;
&lt;TD&gt;Green&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Colors2&lt;/TD&gt;
&lt;TD&gt;Red&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Purple&lt;/TD&gt;
&lt;TD&gt;Yellow&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Orange&lt;/TD&gt;
&lt;TD&gt;Violet&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Colors3&lt;/TD&gt;
&lt;TD&gt;Red&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Black&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Yellow&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;White&lt;/TD&gt;
&lt;TD&gt;Orange&lt;/TD&gt;
&lt;TD&gt;Violet&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Colors4&lt;/TD&gt;
&lt;TD&gt;Red&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Purple&lt;/TD&gt;
&lt;TD&gt;Yellow&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Orange&lt;/TD&gt;
&lt;TD&gt;Violet&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;want:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 480pt;" border="0" width="640" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;Title&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column1&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column2&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column3&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column4&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column5&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column6&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column7&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column8&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Column9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Colors1&lt;/TD&gt;
&lt;TD&gt;Red&lt;/TD&gt;
&lt;TD&gt;Blue&lt;/TD&gt;
&lt;TD&gt;Black&lt;/TD&gt;
&lt;TD&gt;Yellow&lt;/TD&gt;
&lt;TD&gt;Green&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Colors2&lt;/TD&gt;
&lt;TD&gt;Red&lt;/TD&gt;
&lt;TD&gt;Purple&lt;/TD&gt;
&lt;TD&gt;Yellow&lt;/TD&gt;
&lt;TD&gt;Orange&lt;/TD&gt;
&lt;TD&gt;Violet&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Colors3&lt;/TD&gt;
&lt;TD&gt;Red&lt;/TD&gt;
&lt;TD&gt;Black&lt;/TD&gt;
&lt;TD&gt;Yellow&lt;/TD&gt;
&lt;TD&gt;White&lt;/TD&gt;
&lt;TD&gt;Orange&lt;/TD&gt;
&lt;TD&gt;Violet&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;Colors4&lt;/TD&gt;
&lt;TD&gt;Red&lt;/TD&gt;
&lt;TD&gt;Purple&lt;/TD&gt;
&lt;TD&gt;Yellow&lt;/TD&gt;
&lt;TD&gt;Orange&lt;/TD&gt;
&lt;TD&gt;Violet&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 16:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828572#M327293</guid>
      <dc:creator>arde</dc:creator>
      <dc:date>2022-08-13T16:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to: move data from columns to the left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828573#M327294</link>
      <description>&lt;P&gt;May I ask what you plan to do with this data? What is the next analysis or report that will be done once you remove these missing cells?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;What is it you can do without the missing cells that you can't do with the missing cells present?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 17:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828573#M327294</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-13T17:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to: move data from columns to the left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828574#M327295</link>
      <description>&lt;P&gt;Take the opportunity and convert your dataset to a usable long structure.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want (where=(col1 ne ""));
by title;
var column:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Aug 2022 17:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828574#M327295</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-13T17:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to: move data from columns to the left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828583#M327303</link>
      <description>&lt;P&gt;will proc transpose work?&amp;nbsp; I have 10,000 rows in my main file&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 22:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828583#M327303</guid>
      <dc:creator>arde</dc:creator>
      <dc:date>2022-08-13T22:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to: move data from columns to the left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828584#M327304</link>
      <description>&lt;P&gt;I am creating a csv file.&amp;nbsp; the csv file is being used to create a display.&amp;nbsp; I have 10,000 rows.&amp;nbsp; The display doesn't look so nice because of all the gaps in between the data.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 22:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828584#M327304</guid>
      <dc:creator>arde</dc:creator>
      <dc:date>2022-08-13T22:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to: move data from columns to the left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828585#M327305</link>
      <description>&lt;P&gt;There is no harm at all in just trying it as an experiment. Even if it fails it will likely move you closer to a solution.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 22:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828585#M327305</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-08-13T22:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to: move data from columns to the left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828587#M327307</link>
      <description>&lt;P&gt;Below one way how you could do this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover dsd;
  input (Title Column1-Column9) ($);
  datalines;
Colors1,Red,Blue,Black,,Yellow,Green,,,
Colors2,Red,,,Purple,Yellow,,,Orange,Violet
Colors3,Red,,Black,,Yellow,,White,Orange,Violet
Colors4,Red,,,Purple,Yellow,,,Orange,Violet
;

data want;
  set have;
  array _cols {*} Column9 Column8 Column7 Column6 Column5 Column4 Column3 Column2 Column1 ;
  call sortc(of _cols[*]);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1660430434967.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/74420i67FE30C945F81078/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1660430434967.png" alt="Patrick_0-1660430434967.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 22:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828587#M327307</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-08-13T22:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to: move data from columns to the left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828595#M327311</link>
      <description>thank you so much</description>
      <pubDate>Sun, 14 Aug 2022 00:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828595#M327311</guid>
      <dc:creator>arde</dc:creator>
      <dc:date>2022-08-14T00:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to: move data from columns to the left</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828600#M327316</link>
      <description>&lt;PRE&gt;data have;
  infile datalines truncover dsd;
  input (Title Column1-Column9) ($);
  datalines;
Colors1,Red,Blue,Black,,Yellow,Green,,,
Colors2,Red,,,Purple,Yellow,,,Orange,Violet
Colors3,Red,,Black,,Yellow,,White,Orange,Violet
Colors4,Red,,,Purple,Yellow,,,Orange,Violet
;

data want;
  set have(rename=(column1-column9=_c1-_c9));
  array _cols {*} $ _c1-_c9 ;
  array x {*} $ 80 column1-column9 ;
  n=0;
  do i=1 to dim(_cols);
    if not missing(_cols{i}) then do;n+1;x{n}=_cols{i};end;
  end;
  keep Title Column1-Column9;
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Aug 2022 09:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-move-data-from-columns-to-the-left/m-p/828600#M327316</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-08-14T09:49:30Z</dc:date>
    </item>
  </channel>
</rss>

