<?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: How to - Multiply Same Values for Another Specific Datas? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539790#M148799</link>
    <description>&lt;P&gt;Can you post a sample of you what you WANT as output for the input HAVE sample you posted at the top plz?&lt;/P&gt;</description>
    <pubDate>Fri, 01 Mar 2019 22:29:30 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-03-01T22:29:30Z</dc:date>
    <item>
      <title>How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539725#M148759</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to ask a short questions to you. I have a sample data set as below;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Length Variabale1 $ 32 Variable2 $ 32;
Infile Datalines Missover;
Input Variabale1 Variable2;
Datalines;
AA AZA
AA AZB
AA AZC
AB AZA
AB AZB
AB AZC
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And I have values for Variable1 such as AC,AD, AE. At the end of the day, I want to multiply datas for these values. I shared my desired output as below;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Desired.png" style="width: 263px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27613i3F87506292D1A513/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;I want to do it sorted, I mean exact format with the output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody help me about it, please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 17:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539725#M148759</guid>
      <dc:creator>ertr</dc:creator>
      <dc:date>2019-03-01T17:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539727#M148760</link>
      <description>&lt;P&gt;It's actually easier if you keep the VARIABLE1 and VARIABLE2 values separate to start.&amp;nbsp; GIven that you have them together, let's separate them and reassemble the pieces:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table var1_values as select distinct(variable1) from have;&lt;/P&gt;
&lt;P&gt;create table var2_values as select distinct(variable2) from have;&lt;/P&gt;
&lt;P&gt;create table want as select * from var1_values, var2_values order by variable1, variable2;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 18:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539727#M148760</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-01T18:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539731#M148762</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Length Variabale1 $ 32 Variable2 $ 32;
Infile Datalines Missover;
Input Variabale1 Variable2;
Datalines;
AA AZA
AA AZB
AA AZC
AB AZA
AB AZB
AB AZC
Run;

proc sql;
create table want as
select  *
from
(select distinct Variabale1 from have),(select distinct Variable2 from have)
order by Variabale1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Mar 2019 18:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539731#M148762</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-01T18:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539735#M148765</link>
      <description>&lt;P&gt;Test this against proc sql cartesian for performance and let me know&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

Data Have;
Length Variabale1 $ 32 Variable2 $ 32;
Infile Datalines Missover;
Input Variabale1 Variable2;
Datalines;
AA AZA
AA AZB
AA AZC
AB AZA
AB AZB
AB AZC
Run;

proc sql ;                                                              
  create index Variabale1 on have (Variabale1) ;                      
quit ;
data want ;
if _n_=1 then do;
   dcl hash H (dataset:'have(keep=Variable2)',ordered: "A") ;
   h.definekey  ("Variable2") ;
   h.definedone () ;
   dcl hiter hh('h');
   end;
set have end=lr;
by Variabale1;
if first.Variabale1;
do while(hh.next()=0);
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 19:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539735#M148765</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-01T19:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539780#M148793</link>
      <description>&lt;P&gt;I do not think your both codes gives my desired output, are you also tried in your environment? I also do not prefer to use Hash codes.Thank you for your help but do you have any other suggestions?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 22:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539780#M148793</guid>
      <dc:creator>ertr</dc:creator>
      <dc:date>2019-03-01T22:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539782#M148795</link>
      <description>&lt;P&gt;Thank you but your code gives an error. My real purpose append new values under my have data set which you can see&amp;nbsp; also desired data set. Do you have any other ideas for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 22:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539782#M148795</guid>
      <dc:creator>ertr</dc:creator>
      <dc:date>2019-03-01T22:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539783#M148796</link>
      <description>&lt;P&gt;I can't see the error that you are looking at.&amp;nbsp; You might have to post the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have just a small list of new values to add to your existing data?&amp;nbsp; Is that list stored as a data set?&amp;nbsp; It's really not clear what data is available and where values like "AD" and "AE" are coming from.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 22:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539783#M148796</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-01T22:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539790#M148799</link>
      <description>&lt;P&gt;Can you post a sample of you what you WANT as output for the input HAVE sample you posted at the top plz?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 22:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539790#M148799</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-01T22:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539793#M148800</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/90606"&gt;@ertr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You still haven't told us where a value like 'AE' comes from as it's nowhere in your source data. It also would be kind of you if you don't just reply to people that the code proposed errors out but if you'd actually would post the relevant log section as well so people can understand why things didn't work for you.&lt;/P&gt;
&lt;P&gt;Assuming you just want to generate the data below an option:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample(drop=_:);

  length var1 $2 var2 $3;
  _start=rank('A');
  _stop=rank('Z');

  do _i=_start to _stop;
    var1='A'||byte(_i);
    do _j=_start to _start+2;
      var2='AZ'||byte(_j);
      output;
    end;
  end;

  stop;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Mar 2019 22:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539793#M148800</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-01T22:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539810#M148811</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello, Sorry, If I missed something to tell you. Those values coming from nowhere.&amp;nbsp; I mean nowhere such as Excel, data set and etc. We just know it. I found a workaround solution as below, do you have an another idea for this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Length Variabale1 $ 32 Variable2 $ 32;
Infile Datalines Missover;
Input Variabale1 Variable2;
Datalines;
AA AZA
AA AZB
AA AZC
;
Run;
data Want;
set Have(where=(Variabale1="AA"));
do Variabale1="AB", "AC", "AD", "AE";
output;
end;
run;
proc sql noprint;
insert into Have select * from Want;
quit;
Proc Sort DATA=WANT;
BY Variabale1 Variable2;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This one meet my expectation but I want shorter method for this&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 23:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539810#M148811</guid>
      <dc:creator>ertr</dc:creator>
      <dc:date>2019-03-01T23:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Multiply Same Values for Another Specific Datas?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539813#M148813</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/90606"&gt;@ertr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doesn't the code I've posted give you what you're after?&lt;/P&gt;
&lt;P&gt;Just replace line&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; _stop&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token procnames"&gt;rank&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'Z'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; _stop&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token procnames"&gt;rank&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'E'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2019 00:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Multiply-Same-Values-for-Another-Specific-Datas/m-p/539813#M148813</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-02T00:10:09Z</dc:date>
    </item>
  </channel>
</rss>

