<?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: Split one column values to two different columns in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862471#M38103</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440383"&gt;@KranthiK_J&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Tried this, but getting the below error&lt;/P&gt;
&lt;P&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array name for the first argument.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The data step editor is not smart enough to understand that the DIM() function takes an array reference, so it defines _FEATURES as a regular variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could just hard code the upper bound of the DO loop.&lt;/P&gt;
&lt;P&gt;You could move the placement of the ARRAY statement (but that would create the new variables at the start of the dataset instead of the end).&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2023 14:28:49 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-03-06T14:28:49Z</dc:date>
    <item>
      <title>Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862356#M38096</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a column called features which has 9 rows. Now i have to split this 9 rows into 2 new columns equally called as feature_1 and feature_2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets say feature_1 should have 5 rows and feature_2 should have 4 rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample data i have:&lt;/P&gt;&lt;PRE&gt;B_DATE	MOBILE_NUM	FEATURES
1/01/22	204-390-1234	Unlimited Local Talking
1/01/22	204-390-1234	10GB Data Smartphone
1/01/22	204-390-1234	Message Centre
1/01/22	204-390-1234	Call Display
1/01/22	204-390-1234	Unlimited Canadian &amp;amp; Can-US LD
1/01/22	204-390-1234	BCE 5G Access - Corp
1/01/22	204-390-1234	Daily Roam
1/01/22	204-390-1234	Call Forwarding
1/01/22	204-390-1234	Messaging Pack Unlimited&lt;/PRE&gt;&lt;P&gt;Sample Output Expected:&lt;/P&gt;&lt;PRE&gt;B_DATE	MOBILE_NUM	  Feature1	                    Feature2
1/01/22	204-390-4356	Unlimited Local Talking	
1/01/22	204-390-4356	10GB Data Smartphone	       BCE 5G Access - Corp
1/01/22	204-390-4356	Message Centre	               Daily Roam
1/01/22	204-390-4356	Call Display	               Call Forwarding
1/01/22	204-390-4356	Unlimited Canadian &amp;amp; Can-US LD	Messaging Pack Unlimited

&lt;/PRE&gt;&lt;P&gt;Any suggestions would be appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2023 15:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862356#M38096</guid>
      <dc:creator>KranthiK_J</dc:creator>
      <dc:date>2023-03-05T15:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862361#M38097</link>
      <description>&lt;P&gt;Why do you want to split the data in this way? What is the logic used to determine where to split the data?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the real problem, do you have more dates/mobile numbers in your data? If so, it would be helpful to see test data that shows more data.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2023 16:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862361#M38097</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-03-05T16:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862363#M38098</link>
      <description>&lt;P&gt;You don't state WHY this would be a useful thing to do.&amp;nbsp; What is the reason that you want make the data more complicated and less useful?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually this is part of some reporting process where you want to get as much data on the page as possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So here is a method using DO loop and ARRAY.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   do index=1 to dim(_features) until(last.mobile_num);
      set have;
      by r_date mobile_num;
      array _features $50 feature_1 feature_2 ;
      _features[index]=features;
   end;
   drop features;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Mar 2023 16:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862363#M38098</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-05T16:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862392#M38101</link>
      <description>&lt;P&gt;I want to split the data into two columns as it's the requirement for reporting. However, it does have multiple dates with multiple mobile numbers&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2023 22:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862392#M38101</guid>
      <dc:creator>KranthiK_J</dc:creator>
      <dc:date>2023-03-05T22:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862468#M38102</link>
      <description>&lt;P&gt;Tried this, but getting the below error&lt;/P&gt;&lt;P&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array name for the first argument.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 14:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862468#M38102</guid>
      <dc:creator>KranthiK_J</dc:creator>
      <dc:date>2023-03-06T14:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862471#M38103</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440383"&gt;@KranthiK_J&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Tried this, but getting the below error&lt;/P&gt;
&lt;P&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array name for the first argument.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The data step editor is not smart enough to understand that the DIM() function takes an array reference, so it defines _FEATURES as a regular variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could just hard code the upper bound of the DO loop.&lt;/P&gt;
&lt;P&gt;You could move the placement of the ARRAY statement (but that would create the new variables at the start of the dataset instead of the end).&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 14:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862471#M38103</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-06T14:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862506#M38106</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440383"&gt;@KranthiK_J&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to split the data into two columns as it's the requirement for reporting. However, it does have multiple dates with multiple mobile numbers&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you trying to generate a report or trying to generate a dataset?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;If it is a report, it would be better describe the report you want.&amp;nbsp; It's probably possible to generate a report with data in tow columns without actually transforming your data into that format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, can you please expand your example to show how you would want to handle multiple dates / multiple mobile numbers?&amp;nbsp; Is there always the same group of 9 features for each date-mobile number, or can it vary?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 16:07:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862506#M38106</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-03-06T16:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862508#M38107</link>
      <description>&lt;PRE&gt;data want;
   array _charge_descr_en $60 feature_1 feature_2;
   do index=1 to dim(_charge_descr_en) until(last.subscriber_num);
      set EXTRACT_FEATURES;
      by billed_date subscriber_num;
      array _charge_descr $50 feature_1 feature_2 ;
      _charge_descr[index]=features;
   end;
   drop features;
run;&lt;/PRE&gt;&lt;P&gt;I used this one here, however, i am not getting any errors....and also i am not getting any data in feature_1 and feature_2....i am getting nulls in those two columns alone.&lt;/P&gt;&lt;PRE&gt;Billed_Date            Subscriber_num        Feature_1              Feature_2

17DEC2022:00:00:00.000	4038353444                                                                                  		                                                  	                                                  
17DEC2022:00:00:00.000	4038353444                                                                                  	                                                  	                                                  
17DEC2022:00:00:00.000	4038353444                                                                                 		                                                  	                                                  
17DEC2022:00:00:00.000	4038353444                                                                                  		                                                  	                                                  
17DEC2022:00:00:00.000	4038353444                                                                                  		                                                  	                                                  
17DEC2022:00:00:00.000	4038353444                                                                                  		                                                  	                                                  
17DEC2022:00:00:00.000	4038353444                                                                                 	                                                  	                                                  
                                 	                                                  &lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2023 16:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862508#M38107</guid>
      <dc:creator>KranthiK_J</dc:creator>
      <dc:date>2023-03-06T16:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862509#M38108</link>
      <description>&lt;P&gt;Yeah i am trying to generate a report...and i am storing these value in the dataset for future reference as well(history load).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And yes, it always varies....for each mobile number and B_date the features count can vary. It is so dynamic.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 16:11:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862509#M38108</guid>
      <dc:creator>KranthiK_J</dc:creator>
      <dc:date>2023-03-06T16:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862519#M38111</link>
      <description>&lt;P&gt;Make sure to use the same name for the array everywhere.&lt;/P&gt;
&lt;PRE&gt;array _charge_descr_en
dim(_charge_descr_en) 
array _charge_descr
_charge_descr[index]&lt;/PRE&gt;
&lt;P&gt;Try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   do index=1 to 2 until(last.subscriber_num);
      set EXTRACT_FEATURES;
      by billed_date subscriber_num;
      array _charge_descr $60 feature_1 feature_2 ;
      _charge_descr[index]=features;
   end;
   drop features;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2023 16:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862519#M38111</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-06T16:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862541#M38113</link>
      <description>Tried the solution but still having the same result( feature_1 and feature_2 are nulls as output</description>
      <pubDate>Mon, 06 Mar 2023 17:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862541#M38113</guid>
      <dc:creator>KranthiK_J</dc:creator>
      <dc:date>2023-03-06T17:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Split one column values to two different columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862546#M38114</link>
      <description>&lt;P&gt;It is working now, it was my mistake to have a wrong variable.. Thank you so much. Its a life saver.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 17:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-one-column-values-to-two-different-columns/m-p/862546#M38114</guid>
      <dc:creator>KranthiK_J</dc:creator>
      <dc:date>2023-03-06T17:50:46Z</dc:date>
    </item>
  </channel>
</rss>

