<?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 change variable with list of items to variable with single item in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/change-variable-with-list-of-items-to-variable-with-single-item/m-p/78384#M16965</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;BR /&gt;I have a variable with lists of items in it.&lt;BR /&gt;For example,&lt;BR /&gt;a,b&lt;BR /&gt;a,b,e&lt;BR /&gt;b&lt;BR /&gt;e,f,g,h&lt;/P&gt;&lt;P&gt;Does anyone know how to create a new variable with each item having its own row like this:&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;e&lt;BR /&gt;b&lt;BR /&gt;e&lt;BR /&gt;f&lt;BR /&gt;g&lt;BR /&gt;h&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 May 2013 18:49:01 GMT</pubDate>
    <dc:creator>gzr2mz39</dc:creator>
    <dc:date>2013-05-17T18:49:01Z</dc:date>
    <item>
      <title>change variable with list of items to variable with single item</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-variable-with-list-of-items-to-variable-with-single-item/m-p/78384#M16965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;BR /&gt;I have a variable with lists of items in it.&lt;BR /&gt;For example,&lt;BR /&gt;a,b&lt;BR /&gt;a,b,e&lt;BR /&gt;b&lt;BR /&gt;e,f,g,h&lt;/P&gt;&lt;P&gt;Does anyone know how to create a new variable with each item having its own row like this:&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;e&lt;BR /&gt;b&lt;BR /&gt;e&lt;BR /&gt;f&lt;BR /&gt;g&lt;BR /&gt;h&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 18:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-variable-with-list-of-items-to-variable-with-single-item/m-p/78384#M16965</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2013-05-17T18:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: change variable with list of items to variable with single item</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-variable-with-list-of-items-to-variable-with-single-item/m-p/78385#M16966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The basic approach is to parse the string and for each piece extract a value and execute an Output statement. However the actual content may cause issues but for your example, assuming the variable is named Text some thing like this in a data step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length ShortText $ 10; /* or some value large enough to capture the longest substring in Text*/&lt;/P&gt;&lt;P&gt;Do i = 1 to Countw(Text,',');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ShortText=scan(text,i,',');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 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>Fri, 17 May 2013 19:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-variable-with-list-of-items-to-variable-with-single-item/m-p/78385#M16966</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-05-17T19:48:21Z</dc:date>
    </item>
  </channel>
</rss>

