<?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 do I separate the values into two new variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/614857#M18663</link>
    <description>&lt;P&gt;Show us a small example of what the input data set looks like, and what the output data set should look like.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jan 2020 21:08:41 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-01-02T21:08:41Z</dc:date>
    <item>
      <title>How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/614852#M18661</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have input data set with variable&lt;STRONG&gt; Job&lt;/STRONG&gt; , some observation has &lt;STRONG&gt;computer&lt;/STRONG&gt; in the Job variable&amp;nbsp;, and other observations has&lt;STRONG&gt; computer and Electrical&lt;/STRONG&gt;. I want&amp;nbsp;&amp;nbsp;keep all computer in separate new variable and Electrical also into new variable.&lt;/P&gt;&lt;P&gt;please help me how to separate the values with and combined values (&amp;nbsp;computer&lt;STRONG&gt; and &lt;/STRONG&gt;Electrical)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 20:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/614852#M18661</guid>
      <dc:creator>souji</dc:creator>
      <dc:date>2020-01-02T20:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/614857#M18663</link>
      <description>&lt;P&gt;Show us a small example of what the input data set looks like, and what the output data set should look like.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 21:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/614857#M18663</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-02T21:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/614910#M18687</link>
      <description>&lt;P&gt;You don't say what you want the new variables to contain. To create binary variables that signal the presence of a word in the Job string, use the findw function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;computer = findw(job, "computer", " ", 'i');&lt;/P&gt;
&lt;P&gt;electrical = findw(job, "electrical", " ", 'i');&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 05:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/614910#M18687</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-01-03T05:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615038#M18702</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here the details: Input data set has the variable JOB, The variable JOB should contain only one&amp;nbsp;value listed like 'computer' in observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;But some observations have two values listed &amp;nbsp;like ' computer and Electrical'&amp;nbsp; , it is separated by 'and'.&lt;/P&gt;&lt;P&gt;I need to use the word 'and' to identify the second job, if I found that&amp;nbsp;put the second job in a new variable called SecondJob.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me to separate the second job (Electrical)&amp;nbsp;and put that into SecondJob variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 19:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615038#M18702</guid>
      <dc:creator>souji</dc:creator>
      <dc:date>2020-01-03T19:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615051#M18703</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301371"&gt;@souji&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's really only either 1 word or 3 words then using the SCAN() function is a possibility.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input job $40.;
  datalines;
computer and Electrical 
Electrical 
computer
;

data want;
  set have;
  job1=scan(job,1);
  job2=scan(job,3);
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If above doesn't solve your problem then please amend the data step have with additional representative use cases and post it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 19:44:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615051#M18703</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-01-03T19:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615053#M18704</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301371"&gt;@souji&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;here the details: Input data set has the variable JOB, The variable JOB should contain only one&amp;nbsp;value listed like 'computer' in observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;But some observations have two values listed &amp;nbsp;like ' computer and Electrical'&amp;nbsp; , it is separated by 'and'.&lt;/P&gt;
&lt;P&gt;I need to use the word 'and' to identify the second job, if I found that&amp;nbsp;put the second job in a new variable called SecondJob.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is a different explanation than the original explanation you gave.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I said, you need to SHOW us an example of what the input data set looks like, and SHOW us what the final data set should look like. Showing us examples will be a better way to help us provide the proper code than the words you are using.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 20:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615053#M18704</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-03T20:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615089#M18706</link>
      <description>&lt;P&gt;In real life, it would be shocking if all your jobs were a single word.&amp;nbsp; Surely, you should be prepared to separate out:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chief cook and bottle washer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a way to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   split = index(job, ' and ');
   if split then do;
      job2 = substr(job, split + 5);
      job = substr(job, 1, split);
   end;
   drop split;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jan 2020 22:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615089#M18706</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-01-03T22:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615093#M18707</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 22:08:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/615093#M18707</guid>
      <dc:creator>souji</dc:creator>
      <dc:date>2020-01-03T22:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/616659#M18941</link>
      <description>&lt;P&gt;Can you please explain me, why did you put &lt;STRONG&gt;split&lt;/STRONG&gt; and +5 in substr function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; split &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;index&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;job&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;' and '&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; split &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; job2 &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;substr&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;job&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;STRONG&gt;split &lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;5&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; job &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;substr&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;job&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;STRONG&gt;split&lt;/STRONG&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token keyword"&gt;drop&lt;/SPAN&gt; split&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 03:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/616659#M18941</guid>
      <dc:creator>souji</dc:creator>
      <dc:date>2020-01-11T03:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/616660#M18942</link>
      <description>&lt;P&gt;SPLIT is the location where the 5 characters " and " appear.&amp;nbsp; If those characters do not appear, SPLIT will be 0 and the rest of the processing gets skipped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If " and " does appear, SPLIT is the location on the line where it begins.&amp;nbsp; So everything after " and " begins 5 characters later.&amp;nbsp; That's why split+5 appears, and why the SUBSTR function for JOB2 does not have a third parameter.&amp;nbsp; (You may need to read a little about SUBSTR.)&amp;nbsp; Following that, the formula for JOB uses SPLIT to select all the characters before "and ".&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 04:11:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/616660#M18942</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-01-11T04:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/616676#M18946</link>
      <description>&lt;P&gt;can you please provide document to read SUBSTR..I am still in learning stage&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 13:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/616676#M18946</guid>
      <dc:creator>souji</dc:creator>
      <dc:date>2020-01-11T13:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate the values into two new variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/616680#M18947</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301371"&gt;@souji&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that you don't have a local SAS installation (in which case the Help menu and the SAS Documentation Viewer would be available), the &lt;EM&gt;online&lt;/EM&gt; documentation is one of the best sources of information on SAS programming. You can enter keywords (e.g. SUBSTR) into the search field on the documentation homepage, &lt;A href="https://support.sas.com/en/documentation.html" target="_blank" rel="noopener"&gt;https://support.sas.com/en/documentation.html&lt;/A&gt;, but if you know already which category the keyword belongs to (e.g., it's a &lt;EM&gt;function&lt;/EM&gt;), the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=pgmsashome&amp;amp;docsetTarget=home.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;page providing "Quick Links"&lt;/A&gt; to all those categories may be even more helpful. This is because the general search will often result in a large number of hits and, unfortunately (especially for beginners), the most appropriate link will not always be the first of the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, in your example, you would click the link "&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=allprodsle&amp;amp;docsetTarget=syntaxByType-function.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;Functions&lt;/A&gt;" (in section "Language Elements" under "Syntax -&amp;nbsp;Quick Links"), then the letter "&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=allprodsle&amp;amp;docsetTarget=syntaxByType-function.htm&amp;amp;locale=en#p0mk1jlsqnxtssn1lks1wlm9bt1mn0pbh06faefiuyn1paei4vrvft2d" target="_blank" rel="noopener"&gt;S&lt;/A&gt;" and scroll down the alphabetical list until you find "SUBSTR" -- but be prepared to find two or more entries for the same keyword. Avoid any links that refer to (the special topics)&amp;nbsp;&lt;SPAN&gt;DS2 or FedSQL (unless that's what you're interested in) and prefer links that refer to general SAS programming, in this case from the source "Document:&amp;nbsp;&lt;SPAN class="xis-bookTitle"&gt;SAS Functions and CALL Routines: Reference." This leaves you with two links because the SUBSTR function (as an exceptional case) exists in two variants: one "&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0n08xougp40i5n1xw7njpcy0a2b.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;right of =&lt;/A&gt;" (this is appropriate here, see Astounding's code) and one "left of =". Under the most important section "Syntax" you will virtually always find a section containing one or more examples. You should copy these into a SAS session and play around with them to see (and try to understand) how modifications&amp;nbsp;to the code&amp;nbsp;(e.g. function arguments) change the results.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 14:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-separate-the-values-into-two-new-variables/m-p/616680#M18947</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-01-11T14:25:58Z</dc:date>
    </item>
  </channel>
</rss>

