<?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 to split the character variable to multiple variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-the-character-variable-to-multiple-variable/m-p/698909#M213782</link>
    <description>&lt;P&gt;First, I don't understand question 2, and I don't understand where the data comes from. Could you please explain what this screen capture is that you show? Also, please explain if you can get it into a SAS data set, or is it in Excel, or something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For question 1, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards missover;
input str &amp;amp; :$48.;
cards; 
00:00 Lane 1 (North)
Lane 2 (North)
Lane 3 (West)
Lane 4 (East)
All Lanes 
01:00 Lane 1 (North)
;
data want;
	set have;
    index=find(str,'lane','i');
    if index=1 or index=5 then do;
        time=.;
        lane=catx(' ',scan(str,1),scan(str,2));
        direction=scan(str,3);
    end;
    else do;
    	time=input(scan(str,1,' '),time5.);
        lane=catx(' ',scan(str,2),scan(str,3));
        direction=scan(str,4);
    end;
    format time time.;
    drop index;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Nov 2020 20:13:09 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-11-14T20:13:09Z</dc:date>
    <item>
      <title>How to split the character variable to multiple variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-the-character-variable-to-multiple-variable/m-p/698887#M213779</link>
      <description>&lt;P&gt;Hi Community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to split the below character variable (Have) to multiple variable (Time, Lane and Direction).&lt;/P&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;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;All Lanes&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN&gt;01:00&amp;nbsp;&amp;nbsp;Lane&amp;nbsp;1&amp;nbsp;(North)&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN&gt;01:00&amp;nbsp;&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN&gt;Lane&amp;nbsp;1&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;North&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, i have dataset like below in the first two rows of the SAS dataset. Now, i want to use this and create variable. Is there any way that it automatically takes the start date alone and create a variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Have:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS dataset" style="width: 667px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51683i1365B8A5CC862F37/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="SAS dataset" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;SAS dataset&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Want:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I want to create variable called date from the start date mentioned in the description. Also, how to get the variable name from the row 9 ? Is there any way without using rename option?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date&lt;/P&gt;&lt;P&gt;10/09/19&lt;/P&gt;&lt;P&gt;10/09/19&lt;/P&gt;&lt;P&gt;10/09/19&lt;/P&gt;&lt;P&gt;10/09/19&lt;/P&gt;&lt;P&gt;10/09/19&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Nov 2020 17:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-the-character-variable-to-multiple-variable/m-p/698887#M213779</guid>
      <dc:creator>Jannet</dc:creator>
      <dc:date>2020-11-14T17:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to split the character variable to multiple variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-the-character-variable-to-multiple-variable/m-p/698909#M213782</link>
      <description>&lt;P&gt;First, I don't understand question 2, and I don't understand where the data comes from. Could you please explain what this screen capture is that you show? Also, please explain if you can get it into a SAS data set, or is it in Excel, or something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For question 1, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards missover;
input str &amp;amp; :$48.;
cards; 
00:00 Lane 1 (North)
Lane 2 (North)
Lane 3 (West)
Lane 4 (East)
All Lanes 
01:00 Lane 1 (North)
;
data want;
	set have;
    index=find(str,'lane','i');
    if index=1 or index=5 then do;
        time=.;
        lane=catx(' ',scan(str,1),scan(str,2));
        direction=scan(str,3);
    end;
    else do;
    	time=input(scan(str,1,' '),time5.);
        lane=catx(' ',scan(str,2),scan(str,3));
        direction=scan(str,4);
    end;
    format time time.;
    drop index;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Nov 2020 20:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-the-character-variable-to-multiple-variable/m-p/698909#M213782</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-14T20:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to split the character variable to multiple variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-the-character-variable-to-multiple-variable/m-p/698945#M213798</link>
      <description>&lt;PRE&gt;data have;
infile cards missover;
input str &amp;amp; :$48.;
cards; 
00:00 Lane 1 (North)
Lane 2 (North)
Lane 3 (West)
Lane 4 (East)
All Lanes 
01:00 Lane 1 (North)
;
data want;
 set have;
 pid=prxparse('/(\d\d:\d\d)?([^\(\)]+)(\(\w+\))?/o');
 if prxmatch(pid,str) then do;
  a=prxposn(pid,1,str);
  b=prxposn(pid,2,str);
  c=prxposn(pid,3,str);
 end;
 drop pid;
run;
&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Nov 2020 11:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-the-character-variable-to-multiple-variable/m-p/698945#M213798</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-11-15T11:10:58Z</dc:date>
    </item>
  </channel>
</rss>

