<?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: spliting sentence into variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621406#M19626</link>
    <description>&lt;P&gt;Here is my datafile.&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2020 10:42:48 GMT</pubDate>
    <dc:creator>Kyojik</dc:creator>
    <dc:date>2020-01-31T10:42:48Z</dc:date>
    <item>
      <title>spliting sentence into variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621383#M19621</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;I have Ticker, Year and Share_Held. and I want to create Owner1-owner9 from it. as shown below.&lt;/P&gt;&lt;P&gt;Is there any way I can do this in sas. I have a large data which contains multiple companies and each company has multiple years.&lt;/P&gt;&lt;P&gt;Any help will be appreciated. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Ticker&lt;/TD&gt;&lt;TD&gt;year&lt;/TD&gt;&lt;TD&gt;Shares_held&lt;/TD&gt;&lt;TD&gt;Owner1&lt;/TD&gt;&lt;TD&gt;Owner2&lt;/TD&gt;&lt;TD&gt;Owner3&lt;/TD&gt;&lt;TD&gt;Owner4&lt;/TD&gt;&lt;TD&gt;Owner5&lt;/TD&gt;&lt;TD&gt;Owner6&lt;/TD&gt;&lt;TD&gt;Owner7&lt;/TD&gt;&lt;TD&gt;Owner8&lt;/TD&gt;&lt;TD&gt;Owner9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Company&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;Asif Jamil Malik (13.02); Tara Uzra Dawood (11.81); Ayaz Samad Dawood (5.22); Shafqat Sultana (0.019); Muhammad Izqar Khan (0.017); Ahmad Salman Munir (0.017); Tahir Mehmood (0.017); Syed Shabahat Hussain (0.017); Charmaine Hidayatullah (0.017); Syed Farhan Abbas (0.017)&lt;/TD&gt;&lt;TD&gt;13.02&lt;/TD&gt;&lt;TD&gt;11.81&lt;/TD&gt;&lt;TD&gt;5.22&lt;/TD&gt;&lt;TD&gt;0.019&lt;/TD&gt;&lt;TD&gt;0.017&lt;/TD&gt;&lt;TD&gt;0.017&lt;/TD&gt;&lt;TD&gt;0.017&lt;/TD&gt;&lt;TD&gt;0.017&lt;/TD&gt;&lt;TD&gt;0.017&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 31 Jan 2020 07:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621383#M19621</guid>
      <dc:creator>Kyojik</dc:creator>
      <dc:date>2020-01-31T07:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: spliting sentence into variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621387#M19622</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137107"&gt;@Kyojik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use this :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	Ticker = "Company"; output;
	Year = "2019"; output;
	Shares_held = 'Asif Jamil Malik (13.02); Tara Uzra Dawood (11.81); Ayaz Samad Dawood (5.22); Shafqat Sultana (0.019); Muhammad Izqar Khan (0.017); Ahmad Salman Munir (0.017); Tahir Mehmood (0.017); Syed Shabahat Hussain (0.017); Charmaine Hidayatullah (0.017); Syed Farhan Abbas (0.017)';output;
run;


data want;
	set have;
	call symputx ("nb", countw(compress(Shares_held,' ()','A'),";"));
	array owner(&amp;amp;nb);
	do i= 1 to &amp;amp;nb;
		Owner(i) = scan(compress(Shares_held,' ()','A'),i,";");
	end;
	drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;TIP: The compress() function uses '&lt;SPAN&gt;A&lt;/SPAN&gt;&lt;STRONG&gt;' &lt;/STRONG&gt;&lt;SPAN&gt;as modifier which means removing alphabetic characters from the original string.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 08:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621387#M19622</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-31T08:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: spliting sentence into variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621402#M19623</link>
      <description>Thanks for help.&lt;BR /&gt;I am getting following issue.&lt;BR /&gt;&lt;BR /&gt;56 data want;&lt;BR /&gt;57 set Inst_single_PCT;&lt;BR /&gt;58 call symputx ("nb", countw(compress(Inst_single_PCT,' ()','A'),";"));&lt;BR /&gt;59 array owner(&amp;amp;nb);&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;200&lt;BR /&gt;WARNING: Apparent symbolic reference NB not resolved.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, an integer constant, *.&lt;BR /&gt;&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;&lt;BR /&gt;60 do i= 1 to &amp;amp;nb;&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;WARNING: Apparent symbolic reference NB not resolved.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,&lt;BR /&gt;a numeric constant, a datetime constant, a missing value, INPUT, PUT.&lt;BR /&gt;&lt;BR /&gt;61 Owner(i) = scan(compress(Inst_single_PCT,' ()','A'),i,";");&lt;BR /&gt;62 end;&lt;BR /&gt;63 drop i;&lt;BR /&gt;64 run;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Jan 2020 10:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621402#M19623</guid>
      <dc:creator>Kyojik</dc:creator>
      <dc:date>2020-01-31T10:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: spliting sentence into variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621403#M19624</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137107"&gt;@Kyojik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your feedback.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the compress function, it seems that you mention the dataset name (&lt;SPAN&gt;Inst_single_PCT ?) and not the variable ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 10:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621403#M19624</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-31T10:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: spliting sentence into variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621404#M19625</link>
      <description>Hello ed_sas_member,&lt;BR /&gt;my variable and dataset name was same. I changed my variable name but issue remains.&lt;BR /&gt;data want;&lt;BR /&gt;set Inst_single_PCT;&lt;BR /&gt;call symputx ("nb", countw(compress(inst_Single,' ()','A'),";"));&lt;BR /&gt;array owner(&amp;amp;nb);&lt;BR /&gt;do i=1 to &amp;amp;nb;&lt;BR /&gt;Owner(i) = scan(compress(inst_Single,' ()','A'),i,";");&lt;BR /&gt;end;&lt;BR /&gt;drop i;&lt;BR /&gt;run;</description>
      <pubDate>Fri, 31 Jan 2020 10:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621404#M19625</guid>
      <dc:creator>Kyojik</dc:creator>
      <dc:date>2020-01-31T10:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: spliting sentence into variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621406#M19626</link>
      <description>&lt;P&gt;Here is my datafile.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 10:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621406#M19626</guid>
      <dc:creator>Kyojik</dc:creator>
      <dc:date>2020-01-31T10:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: spliting sentence into variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621407#M19627</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137107"&gt;@Kyojik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please provide it as datalines.&lt;/P&gt;
&lt;P&gt;I cannot open your file for security reasons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 10:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621407#M19627</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-31T10:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: spliting sentence into variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621409#M19628</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137107"&gt;@Kyojik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have automatize the process in case you have several rows. Please try it if relevant.&lt;/P&gt;
&lt;P&gt;I cannot help you more without datalines to figure out what is the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bst,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql noprint;
	select max(countw(compress(Inst_single_PCT,' ()','A'),";")) into:max_nb from Inst_single_PCT;
quit;

data want;
	set Inst_single_PCT;
	array owner(&amp;amp;max_nb);
	do i= 1 to countw(compress(Inst_single_PCT,' ()','A'),";");
		Owner(i) = scan(compress(Inst_single_PCT,' ()','A'),i,";");
	end;
	drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Jan 2020 10:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/spliting-sentence-into-variables/m-p/621409#M19628</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-31T10:54:48Z</dc:date>
    </item>
  </channel>
</rss>

