<?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 Comma Delimited Variable Values (need to parse and create additional Obs) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Comma-Delimited-Variable-Values-need-to-parse-and-create/m-p/780253#M248597</link>
    <description>&lt;P&gt;I have a dataset where the Obs have variables that looks like this:&lt;/P&gt;&lt;P&gt;Var1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Var2&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; Var3&lt;/P&gt;&lt;P&gt;121212&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5678,2356,2312&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'5678',2356',2312'&amp;nbsp; // Note single ticks in Var3&lt;/P&gt;&lt;P&gt;Var1 is the primary key to merge on, and character.&lt;/P&gt;&lt;P&gt;However I need to also parse through EITHER Var2 OR Var3 to merge with those values.&lt;/P&gt;&lt;P&gt;Basically, I need to create additional rows (In this case 3) to set up the dataset for another Merge pass.&lt;/P&gt;&lt;P&gt;How best to 'Flip' either Var2 or Var3, generating 3 more obs?&lt;/P&gt;&lt;P&gt;TIA, Jay&lt;/P&gt;&lt;P&gt;SAS EG: 7.15 HFS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Nov 2021 15:07:53 GMT</pubDate>
    <dc:creator>JayS</dc:creator>
    <dc:date>2021-11-15T15:07:53Z</dc:date>
    <item>
      <title>Comma Delimited Variable Values (need to parse and create additional Obs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comma-Delimited-Variable-Values-need-to-parse-and-create/m-p/780253#M248597</link>
      <description>&lt;P&gt;I have a dataset where the Obs have variables that looks like this:&lt;/P&gt;&lt;P&gt;Var1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Var2&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; Var3&lt;/P&gt;&lt;P&gt;121212&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5678,2356,2312&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'5678',2356',2312'&amp;nbsp; // Note single ticks in Var3&lt;/P&gt;&lt;P&gt;Var1 is the primary key to merge on, and character.&lt;/P&gt;&lt;P&gt;However I need to also parse through EITHER Var2 OR Var3 to merge with those values.&lt;/P&gt;&lt;P&gt;Basically, I need to create additional rows (In this case 3) to set up the dataset for another Merge pass.&lt;/P&gt;&lt;P&gt;How best to 'Flip' either Var2 or Var3, generating 3 more obs?&lt;/P&gt;&lt;P&gt;TIA, Jay&lt;/P&gt;&lt;P&gt;SAS EG: 7.15 HFS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 15:07:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comma-Delimited-Variable-Values-need-to-parse-and-create/m-p/780253#M248597</guid>
      <dc:creator>JayS</dc:creator>
      <dc:date>2021-11-15T15:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Delimited Variable Values (need to parse and create additional Obs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comma-Delimited-Variable-Values-need-to-parse-and-create/m-p/780260#M248604</link>
      <description>&lt;P&gt;Are the single ticks intentional in their form? In other words, did you mean to encapsulate each numeric grouping in single quotes ('5678', '2356', '2312') or are they actually like this ('5678', 2356', 2312')?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, what makes you choose `var2` or `var3`? Do you have some conditional reason? Are they always the same?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is how you can output three observations based on your supplied data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
var1 = 121212;
var2 = "5678,2356,2312";
/*var3 = "'5678',2356',2312'";*/
do i = 1 to countw(var2, ",");
	var2_i = scan(var2, i, ",");
	output;
end;
drop var2 i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs var1 var2_i 
1 121212 5678 
2 121212 2356 
3 121212 2312 
&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Nov 2021 15:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comma-Delimited-Variable-Values-need-to-parse-and-create/m-p/780260#M248604</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-11-15T15:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Delimited Variable Values (need to parse and create additional Obs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comma-Delimited-Variable-Values-need-to-parse-and-create/m-p/780262#M248606</link>
      <description>&lt;P&gt;Thanks, I'll take a look...&lt;/P&gt;&lt;P&gt;Best I can figure is when they created the variables they created one with with ticks and one without, no idea why, maybe passing into SQL Statement?&lt;/P&gt;&lt;P&gt;Based on your reply, I'm going to use Var2..&lt;/P&gt;&lt;P&gt;Thanks for your reply...&lt;/P&gt;&lt;P&gt;Jay&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 15:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comma-Delimited-Variable-Values-need-to-parse-and-create/m-p/780262#M248606</guid>
      <dc:creator>JayS</dc:creator>
      <dc:date>2021-11-15T15:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Delimited Variable Values (need to parse and create additional Obs)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comma-Delimited-Variable-Values-need-to-parse-and-create/m-p/780267#M248608</link>
      <description>&lt;P&gt;Thank you, works perfect...&lt;/P&gt;&lt;P&gt;I'll share with balance of the team as others will be processing the data at times.&lt;/P&gt;&lt;P&gt;Thanks Again... Jay&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 16:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comma-Delimited-Variable-Values-need-to-parse-and-create/m-p/780267#M248608</guid>
      <dc:creator>JayS</dc:creator>
      <dc:date>2021-11-15T16:17:17Z</dc:date>
    </item>
  </channel>
</rss>

