<?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 How to Make Row Multiplexing Based on Column? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Make-Row-Multiplexing-Based-on-Column/m-p/540553#M149127</link>
    <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will ask a question which can be little bit difficult to understand the logic. I have two different variables one of them includes four values and the other one includes three values. I need to create my desired table by using values with SAS code( You can see my desired data set in bottom). I know I can easily do it with manual( I can type the values in Excel and then Import to SAS) but I need to automatize this process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure I can do it without Macro with multiple steps(PROC SQL or DATA STEP) or I am not sure how can I do it with macros but I tried to do it macros, I think I am close to do it, I would be so happy, if somebody can help me about it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET Variable1=%STR("SECOND" "THIRD" "FOURTH");
%LET Variable2=%STR("COST" "MAIN" "AMOUNT" "SALARY");
%PUT &amp;amp;Variable1.;
%PUT &amp;amp;Variable2.;
DATA WANT;
LENGTH INFO1 $ 32 INFO2 $ 32 INFO3 $ 32;
INFILE DATALINES MISSOVER;
INPUT INFO1 INFO2 INFO3 ;
DATALINES;
FIRST COST COST
FIRST MAIN MAIN
FIRST AMOUNT AMOUNT
FIRST SALARY SALARY
RUN;

%MACRO INFO_GNR(Var1,Var2);
DATA HAVE;
LENGTH INFO1 $ 32 INFO2 $ 32 INFO3 $ 32;
INFO1=&amp;amp;Var1.;
INFO2=&amp;amp;Var2.;
INFO3=&amp;amp;Var2.;
RUN;

PROC APPEND DATA=HAVE BASE=WANT;
RUN;
%MEND INFO_GNR;
%MACRO LOOP_INFO_GNR;
%LET I=1;
%DO %WHILE(%SCAN(&amp;amp;Variable1.,&amp;amp;I.,%STR( ))~=);
%INFO_GNR(%SCAN(&amp;amp;Variable1.,&amp;amp;I.,%STR( )),%SCAN(&amp;amp;Variable2.,&amp;amp;I.,%STR( )));
%LET I=&amp;amp;I.+1;
%END;
%MEND LOOP_INFO_GNR;
%LOOP_INFO_GNR;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired Output;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Desired.png" style="width: 383px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27678i886C5D1796942266/image-size/large?v=v2&amp;amp;px=999" role="button" title="Desired.png" alt="Desired.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 05 Mar 2019 19:44:14 GMT</pubDate>
    <dc:creator>ertr</dc:creator>
    <dc:date>2019-03-05T19:44:14Z</dc:date>
    <item>
      <title>How to Make Row Multiplexing Based on Column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Make-Row-Multiplexing-Based-on-Column/m-p/540553#M149127</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will ask a question which can be little bit difficult to understand the logic. I have two different variables one of them includes four values and the other one includes three values. I need to create my desired table by using values with SAS code( You can see my desired data set in bottom). I know I can easily do it with manual( I can type the values in Excel and then Import to SAS) but I need to automatize this process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure I can do it without Macro with multiple steps(PROC SQL or DATA STEP) or I am not sure how can I do it with macros but I tried to do it macros, I think I am close to do it, I would be so happy, if somebody can help me about it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET Variable1=%STR("SECOND" "THIRD" "FOURTH");
%LET Variable2=%STR("COST" "MAIN" "AMOUNT" "SALARY");
%PUT &amp;amp;Variable1.;
%PUT &amp;amp;Variable2.;
DATA WANT;
LENGTH INFO1 $ 32 INFO2 $ 32 INFO3 $ 32;
INFILE DATALINES MISSOVER;
INPUT INFO1 INFO2 INFO3 ;
DATALINES;
FIRST COST COST
FIRST MAIN MAIN
FIRST AMOUNT AMOUNT
FIRST SALARY SALARY
RUN;

%MACRO INFO_GNR(Var1,Var2);
DATA HAVE;
LENGTH INFO1 $ 32 INFO2 $ 32 INFO3 $ 32;
INFO1=&amp;amp;Var1.;
INFO2=&amp;amp;Var2.;
INFO3=&amp;amp;Var2.;
RUN;

PROC APPEND DATA=HAVE BASE=WANT;
RUN;
%MEND INFO_GNR;
%MACRO LOOP_INFO_GNR;
%LET I=1;
%DO %WHILE(%SCAN(&amp;amp;Variable1.,&amp;amp;I.,%STR( ))~=);
%INFO_GNR(%SCAN(&amp;amp;Variable1.,&amp;amp;I.,%STR( )),%SCAN(&amp;amp;Variable2.,&amp;amp;I.,%STR( )));
%LET I=&amp;amp;I.+1;
%END;
%MEND LOOP_INFO_GNR;
%LOOP_INFO_GNR;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired Output;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Desired.png" style="width: 383px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27678i886C5D1796942266/image-size/large?v=v2&amp;amp;px=999" role="button" title="Desired.png" alt="Desired.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 19:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Make-Row-Multiplexing-Based-on-Column/m-p/540553#M149127</guid>
      <dc:creator>ertr</dc:creator>
      <dc:date>2019-03-05T19:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to Make Row Multiplexing Based on Column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Make-Row-Multiplexing-Based-on-Column/m-p/540578#M149141</link>
      <description>&lt;P&gt;Why not:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length info1-info3 $8;
do info1 = "FIRST", "SECOND", "THIRD", "FOURTH";
    do info2 = "COST", "MAIN", "AMOUNT", "SALARY";
        info3 = info2;
        output;
        end;
    end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2019 20:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Make-Row-Multiplexing-Based-on-Column/m-p/540578#M149141</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-05T20:46:20Z</dc:date>
    </item>
  </channel>
</rss>

