<?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 Generate values from one Row column transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356528#M83602</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is little bit tricky question to generate&lt;STRONG&gt; commission value&lt;/STRONG&gt;. I have &amp;nbsp;one input dataset, I am stuck in this logic.&lt;/P&gt;&lt;P&gt;Could you Please help me solve it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Please read carefully the Rules as per priority.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Summary of Problem:&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp;Here in below Input data set,to generate commision value , cust wise, every row have different customer like(cust1,cust2,Cust3....till Cust12) column data and their commision amount, base amount,...etc.&amp;nbsp;but here I want data as per commision logic (commission1,commission2......till commission12).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please follow the logic as per Rule priority.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Rule 1 -&amp;nbsp;&lt;/STRONG&gt;We have to take all cust1,cust2,cust3 ...up to cust12 where cust should not be any null &lt;STRONG&gt;value or 0.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ex&lt;/STRONG&gt;- &amp;nbsp;in First row, in all cust column &amp;nbsp;have data, so we should consider. in second row, cust1 doesn't have any data, So it should ignore and if any cust have some value , first on priorty it should check all commision column &amp;nbsp;value,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you see output table in &lt;STRONG&gt;commission&lt;/STRONG&gt; column, all commision value is appearing corresponding to &lt;STRONG&gt;cust&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note- if some where we are getting commission 0 or null value, then we shouldn't take that &lt;STRONG&gt;customer,commission.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Rule 2-&amp;nbsp;&lt;/STRONG&gt;if we are getting commission value, then in output table , base column should store base value to corresponding to commision value from Base column.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ex-&amp;nbsp;&lt;/STRONG&gt;Cust1 (A) has commission 20, and base is 100 is showing in output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Common Rule 3 :- &amp;nbsp;&lt;/STRONG&gt;To generate &lt;STRONG&gt;base, amt, loan column&lt;/STRONG&gt; in output table, we should always take corresponding value to every cust &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;commission.&amp;nbsp;&lt;/STRONG&gt;if it is zero any where for corresponding to commision then it should write&amp;nbsp;&lt;STRONG&gt;0&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;in output table Row 3 &amp;nbsp;logic is little bit different.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once each &lt;STRONG&gt;cust 1,cust2, cust3 ...cust 12 , commision&lt;/STRONG&gt; value will be processed, after finishing &lt;STRONG&gt;every row(before going to second row)&lt;/STRONG&gt;. it should check 1 column of table &lt;STRONG&gt;(Trans_amt).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If &lt;STRONG&gt;trans_amt is null or 0,&lt;/STRONG&gt; then it should ignore,( value should not be loaded in to &lt;STRONG&gt;commision&lt;/STRONG&gt; column.)&lt;/P&gt;&lt;P&gt;else&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Trans_amt&lt;/STRONG&gt; is&amp;nbsp;having some value like 500,600 then it should be loaded in to &lt;STRONG&gt;commission&lt;/STRONG&gt; column, and rest 4 columns should be &lt;STRONG&gt;empty (cust,base,amt,loan).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If you have any doubts related to logic, please let me know, I will clear it.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8744i95F6979330533E55/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="logic.JPG" title="logic.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ritesh&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 May 2017 19:52:20 GMT</pubDate>
    <dc:creator>Riteshdell</dc:creator>
    <dc:date>2017-05-05T19:52:20Z</dc:date>
    <item>
      <title>Generate values from one Row column transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356528#M83602</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is little bit tricky question to generate&lt;STRONG&gt; commission value&lt;/STRONG&gt;. I have &amp;nbsp;one input dataset, I am stuck in this logic.&lt;/P&gt;&lt;P&gt;Could you Please help me solve it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Please read carefully the Rules as per priority.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Summary of Problem:&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp;Here in below Input data set,to generate commision value , cust wise, every row have different customer like(cust1,cust2,Cust3....till Cust12) column data and their commision amount, base amount,...etc.&amp;nbsp;but here I want data as per commision logic (commission1,commission2......till commission12).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please follow the logic as per Rule priority.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Rule 1 -&amp;nbsp;&lt;/STRONG&gt;We have to take all cust1,cust2,cust3 ...up to cust12 where cust should not be any null &lt;STRONG&gt;value or 0.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ex&lt;/STRONG&gt;- &amp;nbsp;in First row, in all cust column &amp;nbsp;have data, so we should consider. in second row, cust1 doesn't have any data, So it should ignore and if any cust have some value , first on priorty it should check all commision column &amp;nbsp;value,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you see output table in &lt;STRONG&gt;commission&lt;/STRONG&gt; column, all commision value is appearing corresponding to &lt;STRONG&gt;cust&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note- if some where we are getting commission 0 or null value, then we shouldn't take that &lt;STRONG&gt;customer,commission.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Rule 2-&amp;nbsp;&lt;/STRONG&gt;if we are getting commission value, then in output table , base column should store base value to corresponding to commision value from Base column.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ex-&amp;nbsp;&lt;/STRONG&gt;Cust1 (A) has commission 20, and base is 100 is showing in output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Common Rule 3 :- &amp;nbsp;&lt;/STRONG&gt;To generate &lt;STRONG&gt;base, amt, loan column&lt;/STRONG&gt; in output table, we should always take corresponding value to every cust &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;commission.&amp;nbsp;&lt;/STRONG&gt;if it is zero any where for corresponding to commision then it should write&amp;nbsp;&lt;STRONG&gt;0&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;in output table Row 3 &amp;nbsp;logic is little bit different.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once each &lt;STRONG&gt;cust 1,cust2, cust3 ...cust 12 , commision&lt;/STRONG&gt; value will be processed, after finishing &lt;STRONG&gt;every row(before going to second row)&lt;/STRONG&gt;. it should check 1 column of table &lt;STRONG&gt;(Trans_amt).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If &lt;STRONG&gt;trans_amt is null or 0,&lt;/STRONG&gt; then it should ignore,( value should not be loaded in to &lt;STRONG&gt;commision&lt;/STRONG&gt; column.)&lt;/P&gt;&lt;P&gt;else&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Trans_amt&lt;/STRONG&gt; is&amp;nbsp;having some value like 500,600 then it should be loaded in to &lt;STRONG&gt;commission&lt;/STRONG&gt; column, and rest 4 columns should be &lt;STRONG&gt;empty (cust,base,amt,loan).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If you have any doubts related to logic, please let me know, I will clear it.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8744i95F6979330533E55/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="logic.JPG" title="logic.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ritesh&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 19:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356528#M83602</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-05-05T19:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values from one Row column transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356533#M83603</link>
      <description>&lt;P&gt;Note that placing summary values (the trans_amt) in another column such as a summary may cause problems down the road.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this may get you started.&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array c cust1 - cust12;
   array b base1 - base12;
   array com commission1- commission12;
   array a amt1 - amt12;
   array l loan1 - loan12;
   do i= 1 to dim(c);
      if not missing(c[i]) and c[i] ne '0' then do;
         cust=c[i];
         commission= com[i];
         base = b[i];
         amt = a[i];
         loan = l[i];
         output;
      end;
   run;&lt;BR /&gt;   /* reset the values prior to the trans_amt output*/
   call missing( cust, commission, base, amt, loan);
   commission = trans_amt;
   output;
   keep cust commission base amt loan ;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 May 2017 20:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356533#M83603</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-05T20:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values from one Row column transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356557#M83614</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;- its not working.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 21:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356557#M83614</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-05-05T21:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values from one Row column transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356561#M83616</link>
      <description>&lt;P&gt;Can you post data (in the form of a data step with CARDS/DATALINES)? &amp;nbsp;We cannot copy and paste from your photograph.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RULE1 Sounds like you mean that your horizontal table has space for 12 repeats but that those with CUST=0 should be ignored? So some input rows will translate to 12 output rows and others to less.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RULE2 and 3 Are confusing. &amp;nbsp;Are you not just copying BASEn to BASE? &amp;nbsp;What are you doing with TAXn? &amp;nbsp;Ignoring it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Row 3 Rule: Sounds like you want to make an extra observation to store the value of the TRANS_AMT column since that column does to apply to any specific customer. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 21:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356561#M83616</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-05T21:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values from one Row column transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356566#M83618</link>
      <description>&lt;P&gt;hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;-&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below I am pasting datastep with data.(reading everything as char)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input Trans_amt $ Cust1 $ base1 $ tax1 $ commission1 $ interest1 $ amt1 $ loan1 $ Cust2 $ base2 $ tax2 $ commission2 $ interest2 $ amt2 $ loan2 $ Cust3 $ base3 $ tax3 $ commission3 $ interest3 $ amt3 $ loan3 $;&lt;BR /&gt;datalines;&lt;BR /&gt;500 A 100 5 20 5 0 4 B 200 4 30 5 0 0 C 300 5 0 6 0 0&lt;BR /&gt;0 0 0 0 0 0 0 0 B 600 2 50 8 0 0 E 500 0 40 8 10 20&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find my comment on your doubts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;doubt1&lt;/STRONG&gt;- &amp;nbsp;you understood correct.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Doubt 2-&lt;/STRONG&gt; &amp;nbsp;Base1,amt1,loan1........base12,amt12,loan12 values will be pasted in Base,amt,loan column , corresponding to commission value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;see in output Row 5-&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cust is E, then we will take commission first (40), then will take corresponding base3,amt3,loan3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Doubt 3&lt;/STRONG&gt;- you understood correct, after reading every row, it should jump to first column (trans_amt).&lt;/P&gt;&lt;P&gt;and then it should check wheaher it is 0 or null then ignore and if some value like 500, then it should paste after reading first row data on commission column, and rest column should be null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 22:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356566#M83618</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-05-05T22:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values from one Row column transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356569#M83619</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43738"&gt;@ritesh&lt;/a&gt;_dellvostro wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;- its not working.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's what happens when no data is available to test. I wasn't going to build your data as I could very well make some assumptions that would not work in the end.&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array c cust1 - cust3;
   array b base1 - base3;
   array com commission1- commission3;
   array a amt1 - amt3;
   array l loan1 - loan3;
   do i= 1 to dim(c);
      if not missing(c[i]) and c[i] ne '0' then do;
         cust=c[i];
         commission= com[i];
         base = b[i];
         amt = a[i];
         loan = l[i];
         output;
      end;
   end;
   /* reset the values prior to the trans_amt output*/
   call missing( cust, commission, base, amt, loan);
   commission = trans_amt;
   output;
   keep cust commission base amt loan ;
run;&lt;/PRE&gt;
&lt;P&gt;The first RUN should have been an END&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 22:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356569#M83619</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-05T22:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values from one Row column transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356570#M83620</link>
      <description>&lt;P&gt;So let's try it with arrays. &amp;nbsp;I modified your variables that look like they should be numbers into numbers.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover ;
input Trans_amt  
  Cust1 $ base1 tax1 commission1 interest1 amt1 loan1 $ 
  Cust2 $ base2 tax2 commission2 interest2 amt2 loan2 $ 
  Cust3 $ base3 tax3 commission3 interest3 amt3 loan3 $
;
datalines;
500 A 100 5 20 5 0 4 B 200 4 30 5 0 0 C 300 5 0 6 0 0
0 0 0 0 0 0 0 0 B 600 2 50 8 0 0 E 500 0 40 8 10 20
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So make arrays for your repeating variables. &amp;nbsp;I used CUST, etc as the array name and _CUST as the target varaibles to save typing. &amp;nbsp;You can change the names if you want.&lt;/P&gt;
&lt;P&gt;Then loop over the array index and copy the values out and write the resulting row. &amp;nbsp;Then handle the extra column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  length row 8 _cust $8 _loan $8 _base _tax _commission _interest _amt 8;
  set have ;
  row+1;
  array cust (3);
  array loan (3);
  array base (3);
  array tax (3);
  array commission (3);
  array interest (3) ;
  array amt (3);
  do i=1 to dim(cust);
    if cust(i) not in ('0',' ') then do;
      _cust=cust(i);
      _loan=loan(i);
      _base=base(i);
      _tax=tax(i);
      _commission=commission(i);
      _interest=interest(i);
      _amt=amt(i);
      output;
    end;
  end;
  call missing(of _cust -- _amt);
  if trans_amt not in (0,.) then do;
    _cust='OTHER';
    _commission=Trans_amt;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you like the result:&lt;/P&gt;
&lt;PRE&gt; Obs    row    _cust    _loan    _base    _tax    _commission    _interest    _amt
  1      1     A         4        100       5          20            5          0
  2      1     B         0        200       4          30            5          0
  3      1     C         0        300       5           0            6          0
  4      1     OTHER                .       .         500            .          .
  5      2     B         0        600       2          50            8          0
  6      2     E         20       500       0          40            8         10
&lt;/PRE&gt;
&lt;P&gt;Then you can drop the original variables and rename the _ prefixed variables to names you like.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 22:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356570#M83620</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-05T22:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values from one Row column transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356601#M83624</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;- your&amp;nbsp;code is almost correct, thanks for it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;just a small note I would like to point-&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See the below output , which is given by you, I marked in yellow/Red,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8753iD5CB9374EA4585ED/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="C.JPG" title="C.JPG" /&gt;&lt;/P&gt;&lt;P&gt;This line should not be come as per logic, I mean Cust3 (C) should be pasted in to table, as I told you the intial logic, to derive only commission where commission should not be null or 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if some where cust has value like C, first always it will check commission , if commission is 0 or null, then it should not consider that customer and corresponding amount (base,tax,interest, etc.....all).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but your code is perfectly working for me, apart from this logic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you could help me for same, I will be thankful for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ritesh&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2017 06:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356601#M83624</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-05-06T06:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values from one Row column transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356602#M83625</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;- I have amended the code as per my requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added my condition in your code and I am getting expected result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if commission(i) not in ('0',' ') then do;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks for your help&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;. I am accepting as solution.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want ;&lt;BR /&gt;length row 8 _cust $8 _loan $8 _base _tax _commission _interest _amt 8;&lt;BR /&gt;set have ;&lt;BR /&gt;row+1;&lt;BR /&gt;array cust (3);&lt;BR /&gt;array loan (3);&lt;BR /&gt;array base (3);&lt;BR /&gt;array tax (3);&lt;BR /&gt;array commission (3);&lt;BR /&gt;array interest (3) ;&lt;BR /&gt;array amt (3);&lt;BR /&gt;do i=1 to dim(cust);&lt;BR /&gt;if cust(i) not in ('0',' ') then do;&lt;BR /&gt;if commission(i) not in ('0',' ') then do;&lt;BR /&gt;_cust=cust(i);&lt;BR /&gt;_commission=commission(i);&lt;BR /&gt;_base=base(i);&lt;BR /&gt;/* _tax=tax(i); */&lt;BR /&gt;_amt=amt(i);&lt;BR /&gt;_loan=loan(i);&lt;BR /&gt;/* _interest=interest(i); */&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;call missing(of _cust -- _amt);&lt;BR /&gt;if trans_amt not in (0,.) then do;&lt;BR /&gt;_cust='';&lt;BR /&gt;_commission=Trans_amt;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2017 06:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-values-from-one-Row-column-transpose/m-p/356602#M83625</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-05-06T06:43:59Z</dc:date>
    </item>
  </channel>
</rss>

