<?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: creating dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586057#M167259</link>
    <description>&lt;P&gt;Please try, hope this is what you are expecting&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines;
input jobcod $1-40;
if indexw(jobcod,'and')&amp;gt;0 then before=substr(jobcod,1,indexw(jobcod,'and')-1);
if indexw(jobcod,'and')&amp;gt;0 then after=substr(jobcod,indexw(jobcod,'and')+3);
datalines;
biostats
computer eng and architect
scientist and actor
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 04 Sep 2019 11:35:16 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2019-09-04T11:35:16Z</dc:date>
    <item>
      <title>creating dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586054#M167257</link>
      <description>&lt;P&gt;data test;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input jobcod $1-40;&lt;BR /&gt;datalines;&lt;BR /&gt;biostats&lt;BR /&gt;computer eng and architect&lt;BR /&gt;scientist and actor&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=test;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have created above dataset.&lt;/P&gt;&lt;P&gt;and i want to create two variable using above dataset data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;first variable should contain the data before "and"&lt;/P&gt;&lt;P&gt;second variable should contains the data after "and".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can anyone suggest the code for that?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 11:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586054#M167257</guid>
      <dc:creator>Soham0707</dc:creator>
      <dc:date>2019-09-04T11:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: creating dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586056#M167258</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set test;
    if indexw(jobcod, 'and') then do;
        before=substr(jobcod, 1, indexw(jobcod, 'and')-1);
        after=substr(jobcod, indexw(jobcod, 'and') +4);
    end;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 11:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586056#M167258</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-09-04T11:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: creating dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586057#M167259</link>
      <description>&lt;P&gt;Please try, hope this is what you are expecting&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines;
input jobcod $1-40;
if indexw(jobcod,'and')&amp;gt;0 then before=substr(jobcod,1,indexw(jobcod,'and')-1);
if indexw(jobcod,'and')&amp;gt;0 then after=substr(jobcod,indexw(jobcod,'and')+3);
datalines;
biostats
computer eng and architect
scientist and actor
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 11:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586057#M167259</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-04T11:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: creating dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586060#M167260</link>
      <description>&lt;P&gt;Alternatively with perl regular expression using the prxmatch and prxchange functions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines;
input jobcod $1-40;
if prxmatch('m/\band\b/',jobcod) then do;
before=prxchange('s/(.*)(and.*)/$1/',-1,jobcod);
after=prxchange('s/(.*and)(.*)/$2/',-1,jobcod);
end;
datalines;
biostats
computer eng and architect
scientist and actor
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 11:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586060#M167260</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-04T11:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: creating dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586065#M167262</link>
      <description>&lt;P&gt;"AND" to "TAB" for safe bet and scan&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;
infile datalines;
input jobcod $1-40;
datalines;
biostats
computer eng and architect
scientist and actor
;
run;

data want;
set test;
w=tranwrd(jobcod,'and','09'x);
before=scan(w,1,'09'x);
after=scan(w,2,'09'x);
drop w;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 11:57:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586065#M167262</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-04T11:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: creating dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586097#M167279</link>
      <description>&lt;P&gt;Thank you so much..&lt;/P&gt;&lt;P&gt;got what i want.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 13:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586097#M167279</guid>
      <dc:creator>Soham0707</dc:creator>
      <dc:date>2019-09-04T13:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: creating dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586106#M167281</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines;
input jobcod $1-40;
p=prxmatch('m/\band\b/',jobcod);
if p then do;
before=substr(jobcod,1,p-1);
after=substr(jobcod,p+4);
end;
datalines;
biostats
computer eng and architect
scientist and actor
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 13:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dataset/m-p/586106#M167281</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-04T13:29:01Z</dc:date>
    </item>
  </channel>
</rss>

