<?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: Splitting of variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Splitting-of-variable/m-p/850126#M37207</link>
    <description>Variable name major contains observation as computer science and enginnering, maths and english, science and maths.the variable name major should contain only names before word 'and' such as 1.computer science 2.maths 3.science which is words before 'and' and another variable major2 should contain 1.engineering 2.English 3.maths which is after word 'and'.</description>
    <pubDate>Fri, 16 Dec 2022 18:14:16 GMT</pubDate>
    <dc:creator>Mohana1</dc:creator>
    <dc:date>2022-12-16T18:14:16Z</dc:date>
    <item>
      <title>Splitting of variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Splitting-of-variable/m-p/850117#M37205</link>
      <description>If i am having a column of computer science and engineering,maths and english,science and social,electronics engineering and maths ,how to separate a single column of variables into two columns before and after 'and'.</description>
      <pubDate>Fri, 16 Dec 2022 17:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Splitting-of-variable/m-p/850117#M37205</guid>
      <dc:creator>Mohana1</dc:creator>
      <dc:date>2022-12-16T17:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting of variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Splitting-of-variable/m-p/850119#M37206</link>
      <description>&lt;P&gt;Your question isn't clear.&amp;nbsp; Please provide the SAS code (data step code) to generate an example of the data you have, and then show the data you want.&amp;nbsp; Also please share the code you have tried.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 17:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Splitting-of-variable/m-p/850119#M37206</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-12-16T17:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting of variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Splitting-of-variable/m-p/850126#M37207</link>
      <description>Variable name major contains observation as computer science and enginnering, maths and english, science and maths.the variable name major should contain only names before word 'and' such as 1.computer science 2.maths 3.science which is words before 'and' and another variable major2 should contain 1.engineering 2.English 3.maths which is after word 'and'.</description>
      <pubDate>Fri, 16 Dec 2022 18:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Splitting-of-variable/m-p/850126#M37207</guid>
      <dc:creator>Mohana1</dc:creator>
      <dc:date>2022-12-16T18:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting of variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Splitting-of-variable/m-p/850148#M37212</link>
      <description>&lt;P&gt;So first let's convert your words into an actual dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input major $60.;
cards;
computer science and enginnering
math and english
science and math
math
english
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now we can start writing some code to try to solve the problem.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
* Copy the data so SAS will guess that you want MAJOR1 and MAJOR2 defined 
  as the same type and length as MAJOR
;
  major1=major;
  major2=major;
* Check if the word AND appears ;
  location=findw(major,'and',' ','i');
* Split when found ; 
  if location then do;
    major1 = substr(major,1,location-1);
    major2 = left(substrn(major,location+4));
  end;
  else major2=' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1671223518554.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78644i177173FEE014A43F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1671223518554.png" alt="Tom_0-1671223518554.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS Clearly there aren't any English majors as they don't know how to spell ENGINEERING or MATH.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 20:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Splitting-of-variable/m-p/850148#M37212</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-16T20:46:24Z</dc:date>
    </item>
  </channel>
</rss>

