<?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: Sas: Columns multiplication with their corresponding variable names in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255119#M57034</link>
    <description>&lt;P&gt;It works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Seem like you are doing transpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie date x_height x_weight y_height y_weight&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; 1990 100 &amp;nbsp; &amp;nbsp; &amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;80 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;40&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; 1991 90 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;70 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;35&lt;/P&gt;
&lt;P&gt;&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; &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;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date ID weight &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;date ID height&lt;/P&gt;
&lt;P&gt;1990 X 50 &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; &amp;nbsp; &amp;nbsp; 1990 X 100&lt;/P&gt;
&lt;P&gt;1991 X 45 &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; &amp;nbsp; &amp;nbsp; 1991 X 90&lt;/P&gt;
&lt;P&gt;1990 Y 40 &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; &amp;nbsp; &amp;nbsp; 1990 Y 80&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then do multiplication. After which I need to transpose back to this format&lt;/P&gt;
&lt;P&gt;date x_wh y_wh etc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In matlab,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can simply do column multiplication ie column 1 * column 2, column 3 * column 4 after I have sorted the column positions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hmmmmm&lt;/P&gt;
&lt;P&gt;anyway thanks for your answer&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2016 22:39:03 GMT</pubDate>
    <dc:creator>CheerfulChu</dc:creator>
    <dc:date>2016-03-07T22:39:03Z</dc:date>
    <item>
      <title>Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/254997#M57019</link>
      <description>&lt;P&gt;Dear Sir,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could not find the answers in google. I have a dataset with many columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The columns&amp;nbsp;are labeled as&lt;/P&gt;
&lt;P&gt;X_height, &amp;nbsp;X_weight, Y_height , Y_weight ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I multiply height with weight for the same pair. ie X_height * X_weight, Y_height * Y_weight.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;Leo&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 16:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/254997#M57019</guid>
      <dc:creator>CheerfulChu</dc:creator>
      <dc:date>2016-03-07T16:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255012#M57020</link>
      <description>&lt;P&gt;Well, I suppose the first question is why do you have data like that? &amp;nbsp;Normally a normalised - i.e. data down the page rather than across is far easier to work with. &amp;nbsp;If you have to work with a transposed dataset, then you should at least try to make it easy for youself. &amp;nbsp;For example naming the variables:&lt;/P&gt;
&lt;P&gt;height1 height2 height3 weight1 weight2 etc.&lt;/P&gt;
&lt;P&gt;Then you can simply setup arrays:&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; array weight{3};&lt;/P&gt;
&lt;P&gt;&amp;nbsp; array height{3};&lt;/P&gt;
&lt;P&gt;&amp;nbsp; array results{3};&lt;/P&gt;
&lt;P&gt;&amp;nbsp; do i=1 to 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; results{i}=height{i} * weight{i};&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However again, you would be better off sorting your data out first so you have:&lt;/P&gt;
&lt;P&gt;RECORD_ID &amp;nbsp; WEIGHT &amp;nbsp; HEIGHT&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxx &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xxx&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxx &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xxx&lt;/P&gt;
&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxx &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xxx&lt;/P&gt;
&lt;P&gt;It will make your life and your coding far easier.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 17:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255012#M57020</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-07T17:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255027#M57021</link>
      <description>&lt;P&gt;You could also generate the code using macros, or using arrays.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain your situation a bit more, sample input and desired output is helpful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 17:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255027#M57021</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-07T17:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255031#M57022</link>
      <description>&lt;P&gt;Hi Sir,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very good suggestion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Well, I suppose the first question is why do you have data like that? &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;gt;&amp;gt; I cant simply rename X, Y as 1 and 2 is because X and Y actually represent a 8 character ID. These IDs are needed later in a process to identify them. This dataset has over 1000 unique ID. I thought if I transpose them, I can calculate them easier in a matrix form. But seem like I cant pair them up like X_weight * X_height, Y_weight * Y_height ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Seem like Sas has a limitation here.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 17:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255031#M57022</guid>
      <dc:creator>CheerfulChu</dc:creator>
      <dc:date>2016-03-07T17:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255033#M57023</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input:&lt;/P&gt;
&lt;P&gt;Date X_height X_weight Y_height Y_weight&lt;/P&gt;
&lt;P&gt;1990 &amp;nbsp; &amp;nbsp; 100 &amp;nbsp; &amp;nbsp; &amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;40&lt;/P&gt;
&lt;P&gt;1991 &amp;nbsp; &amp;nbsp; &amp;nbsp;80 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;40 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;300 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output&lt;/P&gt;
&lt;P&gt;Date X_hw Y_hw&lt;/P&gt;
&lt;P&gt;1990 5000 &amp;nbsp; 8000&lt;/P&gt;
&lt;P&gt;1991 3200 &amp;nbsp; 9000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 18:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255033#M57023</guid>
      <dc:creator>CheerfulChu</dc:creator>
      <dc:date>2016-03-07T18:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255037#M57024</link>
      <description>&lt;P&gt;I guess I don't understand the problem. Are you trying to generate the names programmatically? If you know the names you want then just use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
input Date X_height X_weight Y_height Y_weight;
X_hw = X_Height * X_Weight;
Y_hw = Y_Height * Y_Weight;
datalines;
1990     100       50            200        40
1991      80        40            300        30
;

proc print;
var Date X_hw Y_hw;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 18:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255037#M57024</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-03-07T18:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255042#M57025</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a large dataset with 1000 pair of columns:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For simplicity,&lt;/P&gt;
&lt;P&gt;Input&lt;/P&gt;
&lt;P&gt;Date X_height X_weight Y_height Y_weight Z&lt;SPAN&gt;_height Z_weight etc&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Output:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Date X_hw Y_hw X Z_hw etc&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So there would be 1000 variables name of X, Y, Z etc. These are 8 unique characters ID. Is there a way to pair them up according to their ID and do the multiplication? Else I have to explicit write out the mulitiplication as you did for 1000 IDs.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Leo&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 18:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255042#M57025</guid>
      <dc:creator>CheerfulChu</dc:creator>
      <dc:date>2016-03-07T18:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255044#M57026</link>
      <description>&lt;P&gt;Could you please tell us realistinc names of the variables for 5 pairs? If you have 1000 pairs of variables, then obviously the prefixes are more complicated than "A_" through "Z_".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 18:27:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255044#M57026</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-03-07T18:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255048#M57027</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sure.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie ASU0T12 ASU11GT BSU891G. 7 characters using A-Z and 0-9&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 18:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255048#M57027</guid>
      <dc:creator>CheerfulChu</dc:creator>
      <dc:date>2016-03-07T18:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255049#M57028</link>
      <description>&lt;P&gt;Here's a way to restructure your data ... not easy, but not terribly lengthy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data heights (keep=ID height) weights (keep=ID weight);&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array nums {*} _numeric_;&lt;/P&gt;
&lt;P&gt;do _n_=1 to dim(nums);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; test_name = upcase(vname(nums{_n_}));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if scan(test_name,2, '_') = 'HEIGHT' then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id = scan(test_name, 1, '_');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height = nums{_n_};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output heights;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; else if scan(test_name, 2, '_') = 'WEIGHT' then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id = scan(test_name, 1, '_');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; weight = nums{_n_};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output weights;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=heights;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=weights;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data combined;&lt;/P&gt;
&lt;P&gt;merge heights weights;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;product = height * weight;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's untested code, but should be fine.&amp;nbsp; And I agree that this would be a much better form for storing the data.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 18:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255049#M57028</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-07T18:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255119#M57034</link>
      <description>&lt;P&gt;It works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Seem like you are doing transpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie date x_height x_weight y_height y_weight&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; 1990 100 &amp;nbsp; &amp;nbsp; &amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;80 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;40&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; 1991 90 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;70 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;35&lt;/P&gt;
&lt;P&gt;&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; &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;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date ID weight &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;date ID height&lt;/P&gt;
&lt;P&gt;1990 X 50 &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; &amp;nbsp; &amp;nbsp; 1990 X 100&lt;/P&gt;
&lt;P&gt;1991 X 45 &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; &amp;nbsp; &amp;nbsp; 1991 X 90&lt;/P&gt;
&lt;P&gt;1990 Y 40 &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; &amp;nbsp; &amp;nbsp; 1990 Y 80&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then do multiplication. After which I need to transpose back to this format&lt;/P&gt;
&lt;P&gt;date x_wh y_wh etc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In matlab,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can simply do column multiplication ie column 1 * column 2, column 3 * column 4 after I have sorted the column positions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hmmmmm&lt;/P&gt;
&lt;P&gt;anyway thanks for your answer&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 22:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255119#M57034</guid>
      <dc:creator>CheerfulChu</dc:creator>
      <dc:date>2016-03-07T22:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255153#M57037</link>
      <description>&lt;P&gt;If you had told us that you are a MATLAB user, we could have suggested a very simple SAS/IML solution. IML is the SAS Interactive Mtrix Language, which is very close to MATLAB. Also, it looks like the variables that you want multiplied are adjacent to each other, which was not clear from your initial description.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a SAS/IML solution, which might be more to your liking:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input Date X_height X_weight Y_height Y_weight;
datalines;
1990     100       50            200        40
1991      80        40            300        30
;

proc iml;
use Have(drop=Date);
read all var _NUM_ into M[colname=varNames];
close Have;

odds = do(1, ncol(M), 2);               /* odd columns */
evens = odds + 1;                       /* even columns */
mult = M[ , evens] # M[ , odds];        /* multiply adjacent values */

prefix = substr(varNames[,odds], 1, 7); /* extract 7-character prefix */
names = prefix + "_hw";                 /* append comon suffix */
create MultOut from Mult[colname=names];/* output to data set */
append from Mult;
close MultOut;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Mar 2016 01:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255153#M57037</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-03-08T01:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255154#M57038</link>
      <description>I think declaring three arrays - one to hold x, one to hold y and one to hold results. You need to ensure the variables are listed in the same order in the array declaration. If you have some rules you can use sashelp.vcolumn to develop macro variables that hold the value. &lt;BR /&gt;&lt;BR /&gt;Data want;&lt;BR /&gt;Set have;&lt;BR /&gt;Array x(1000) x_1-x_1000;&lt;BR /&gt;Array y(1000) y_1-y_1000;&lt;BR /&gt;Array r(1000) r_1-r_1000;&lt;BR /&gt;&lt;BR /&gt;Do i=1 to dim(x);&lt;BR /&gt;R(i)=x(i)*y(i);&lt;BR /&gt;End;&lt;BR /&gt;Run; &lt;BR /&gt;&lt;BR /&gt;But having a data set that is 3000 columns sounda horrid. I would go with the transpose solution. You can look up a paper called a better way to flip that has a macro to easily transpose data sets.</description>
      <pubDate>Tue, 08 Mar 2016 02:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255154#M57038</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-08T02:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255168#M57039</link>
      <description>&lt;P&gt;Assuming the order as what you showed. you can use the following code to name variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Date X_height X_weight Y_height Y_weight;
cards;
1990     100       50            200        40
1991      80        40            300        30
;
run;
data temp;
 set sashelp.vcolumn(keep=libname memname name
 where=(libname='WORK' and memname='HAVE' and upcase(name) ne 'DATE'));
 flag=mod(_n_,2);
run;

data _null_;
 merge temp(keep=name flag where=(flag=1)) 
 temp(keep=name flag where=(flag=0) rename=(name=_name)) end=last;
 if _n_ eq 1 then call execute('proc sql;create table want as select date');
 call execute(',');
 call execute(cat(strip(name),'*',strip(_name),' as ',strip(scan(name,1,'_')),'_',strip(scan(name,2,'_')),'_',strip(scan(_name,2,'_')))) ;
 if last then call execute('from have;quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Mar 2016 05:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255168#M57039</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-08T05:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sas: Columns multiplication with their corresponding variable names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255386#M57059</link>
      <description>I keep the date within the proc iml. &lt;BR /&gt;&lt;BR /&gt;proc iml;&lt;BR /&gt;  use Have;&lt;BR /&gt;  read all var _NUM_ into M[colname=varNames];&lt;BR /&gt;  close Have;&lt;BR /&gt;  &lt;BR /&gt;  evens = do(2, ncol(M), 2);&lt;BR /&gt;  odds  = evens + 1;&lt;BR /&gt;  mult = M[ , evens] # M[ , odds];&lt;BR /&gt;  mult =M[, 1] || mult;&lt;BR /&gt;  prefix = substr(varNames[,odds], 1, 7);&lt;BR /&gt;  names = prefix + "_hw";&lt;BR /&gt;  bnames= varNames[1]|| names;&lt;BR /&gt;  create MultOut from Mult[colname= bnames];&lt;BR /&gt;  append from Mult;&lt;BR /&gt;  close MultOut;&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;</description>
      <pubDate>Tue, 08 Mar 2016 22:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sas-Columns-multiplication-with-their-corresponding-variable/m-p/255386#M57059</guid>
      <dc:creator>CheerfulChu</dc:creator>
      <dc:date>2016-03-08T22:25:40Z</dc:date>
    </item>
  </channel>
</rss>

