<?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 How to reshape comma-delimited values in SAS dataset? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137685#M27843</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a SAS dataset as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data source;&lt;/P&gt;&lt;P&gt;input id cols $10.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 gender,age&lt;/P&gt;&lt;P&gt;2 address&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I would like to transpose those values in COLS column which is currently separated by a comma. The target dataset is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data target;&lt;/P&gt;&lt;P&gt;input id cols $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 gender&lt;/P&gt;&lt;P&gt;1 age&lt;/P&gt;&lt;P&gt;2 address&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How will I be able to achieve the target dataset? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Jan 2015 07:31:28 GMT</pubDate>
    <dc:creator>angeliquec</dc:creator>
    <dc:date>2015-01-26T07:31:28Z</dc:date>
    <item>
      <title>How to reshape comma-delimited values in SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137685#M27843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a SAS dataset as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data source;&lt;/P&gt;&lt;P&gt;input id cols $10.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 gender,age&lt;/P&gt;&lt;P&gt;2 address&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I would like to transpose those values in COLS column which is currently separated by a comma. The target dataset is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data target;&lt;/P&gt;&lt;P&gt;input id cols $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 gender&lt;/P&gt;&lt;P&gt;1 age&lt;/P&gt;&lt;P&gt;2 address&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How will I be able to achieve the target dataset? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 07:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137685#M27843</guid>
      <dc:creator>angeliquec</dc:creator>
      <dc:date>2015-01-26T07:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to reshape comma-delimited values in SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137686#M27844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data source;&lt;/P&gt;&lt;P&gt;input id cols $10.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 gender,age&lt;/P&gt;&lt;P&gt;2 address&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data source2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set source;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 1 to 2;&lt;/P&gt;&lt;P&gt; new_cols=scan(cols,i,',');&lt;/P&gt;&lt;P&gt; if new_cols ne '';&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 08:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137686#M27844</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-01-26T08:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to reshape comma-delimited values in SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137687#M27845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data source;&lt;/P&gt;&lt;P&gt;input id cols $10.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 gender,age&lt;/P&gt;&lt;P&gt;2 address&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data source2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set source;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 1 to countw(cols,',');&lt;/P&gt;&lt;P&gt;new_cols=scan(cols,i,',');&lt;/P&gt;&lt;P&gt;if new_cols ne '';&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 08:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137687#M27845</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-26T08:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to reshape comma-delimited values in SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137688#M27846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you xia keshan!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 09:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137688#M27846</guid>
      <dc:creator>angeliquec</dc:creator>
      <dc:date>2015-01-26T09:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to reshape comma-delimited values in SAS dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137689#M27847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting. From the SAS documentation for the subsetting if:&lt;/P&gt;&lt;P&gt;If the expression is false (its value is 0 or missing), no further statements are processed for that observation or record, the current observation is not written to the data set, and the &lt;STRONG&gt;remaining program statements in the DATA step&lt;/STRONG&gt; are not executed. SAS immediately returns to the beginning of the DATA step because the subsetting IF statement does not require additional statements to stop processing observations.&lt;/P&gt;&lt;P&gt;(emphasis by me)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would imply that a value for cols of "Age,,Gender" would lead to "Gender" being dropped, but that does actually not happen. SAS only exits the do loop.&lt;/P&gt;&lt;P&gt;Learning never stops.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 09:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reshape-comma-delimited-values-in-SAS-dataset/m-p/137689#M27847</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-01-26T09:45:36Z</dc:date>
    </item>
  </channel>
</rss>

