<?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: Cut the variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cut-the-variable/m-p/234859#M42981</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code:&lt;/P&gt;
&lt;PRE&gt;phone=catx(', ',scan(phone,1,','),scan(phone,2,','));
&lt;/PRE&gt;
&lt;P&gt;Should od the trick, or:&lt;/P&gt;
&lt;PRE&gt;phone=substr(phone,1,findc(phone,',',index(phone,',')+1));&lt;/PRE&gt;
&lt;P&gt;Note, haven't tested the second, might need a tinker or two to work. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However the question should really be, why do you have multiple data elements in one variable. &amp;nbsp;This is not a good way to do things, keep you underlying data separated out for easy processing, then concatenate at report time. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  set have; 
  array phone{4} $20.;
  do i=1 to 4;
    phone{i}=scan(phone,i,',');
  end;
run;
    &lt;/PRE&gt;
&lt;P&gt;You can then do anything you want with variables phone1-phone4.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Nov 2015 13:21:20 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-11-16T13:21:20Z</dc:date>
    <item>
      <title>Cut the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cut-the-variable/m-p/234856#M42980</link>
      <description>&lt;P&gt;I have a tabel as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;phone&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0112976555559, 2955940123, 4072948756, 4071453259&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4072564138&lt;/P&gt;
&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3051485236, 4078596321, 4072483516&lt;/P&gt;
&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1254862, 4075847456&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need only first 2 phones like this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; phone&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0112976555559, 2955940123&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4072564138&lt;/P&gt;
&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3051485236, 4078596321&lt;/P&gt;
&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1254862, 4075847456&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2015 13:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cut-the-variable/m-p/234856#M42980</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2015-11-16T13:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Cut the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cut-the-variable/m-p/234859#M42981</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code:&lt;/P&gt;
&lt;PRE&gt;phone=catx(', ',scan(phone,1,','),scan(phone,2,','));
&lt;/PRE&gt;
&lt;P&gt;Should od the trick, or:&lt;/P&gt;
&lt;PRE&gt;phone=substr(phone,1,findc(phone,',',index(phone,',')+1));&lt;/PRE&gt;
&lt;P&gt;Note, haven't tested the second, might need a tinker or two to work. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However the question should really be, why do you have multiple data elements in one variable. &amp;nbsp;This is not a good way to do things, keep you underlying data separated out for easy processing, then concatenate at report time. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  set have; 
  array phone{4} $20.;
  do i=1 to 4;
    phone{i}=scan(phone,i,',');
  end;
run;
    &lt;/PRE&gt;
&lt;P&gt;You can then do anything you want with variables phone1-phone4.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2015 13:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cut-the-variable/m-p/234859#M42981</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-16T13:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cut the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cut-the-variable/m-p/234865#M42983</link>
      <description>&lt;P&gt;Here is regular expression.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards missover;
input id      phone &amp;amp;$200.;
_phone=prxchange('s/(^\d+,\d+).*/$1/',-1,phone);
cards;
1             0112976555559,2955940123,4072948756,4071453259
2             4072564138
3             3051485236,4078596321,4072483516
4             1254862,4075847456
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Nov 2015 14:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cut-the-variable/m-p/234865#M42983</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2015-11-16T14:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: Cut the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cut-the-variable/m-p/234873#M42987</link>
      <description>&lt;P&gt;Here is an alternative approach similar to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length new $100;
set have;
do i=1 to 2 ;
new=catx(',',new,scan(phone,i,','));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Nov 2015 15:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cut-the-variable/m-p/234873#M42987</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-11-16T15:36:57Z</dc:date>
    </item>
  </channel>
</rss>

