<?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: #Doubt regarding the flow of the code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427568#M105483</link>
    <description>&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;'s explanation but, given your code, VendorMoney won't even be in tourdetails since you drop that variable in your code. Also, you create sortcars in your proc sort step, but then set sortcar in your datastep. Obviously, the output you posted was not from the code you posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 14 Jan 2018 22:54:05 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2018-01-14T22:54:05Z</dc:date>
    <item>
      <title>#Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427559#M105475</link>
      <description>&lt;PRE class="xis-code"&gt;&lt;BR /&gt;&lt;BR /&gt;proc sort data=cars out=sortcars;
   by type;
run;

data tourdetails
     vendordetails;
   set sortcar;
   by type;
   Money=Wheelbase *Length;
   output tourdetails;
   if First.type then
      do;
         VendorMoney=0;
      end;
   VendorMoney + Money;
   if Last.type then output vendordetails;
run;

proc print data=tourdetails;
   title 'Detail Records: Dollars Spent on Individual Tours';
run;

proc print data=vendordetails;
   title 'Vendor Totals: Dollars Spent and Bookings by Vendor';
run;&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;iam new to SAS, can someone please explain me the flow of the code??&lt;/P&gt;&lt;P&gt;i have attached the input data below.&lt;/P&gt;&lt;P&gt;what will be the output?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 23:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427559#M105475</guid>
      <dc:creator>Hemanth003</dc:creator>
      <dc:date>2018-01-14T23:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: #Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427560#M105476</link>
      <description>&lt;P&gt;Hi, what doubt do you have?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 22:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427560#M105476</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-14T22:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: #Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427561#M105477</link>
      <description>&lt;P&gt;please check the output file below, why there is a zero in the tourdetails&amp;nbsp;tables first field whereas vendor details doesn't have it&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 22:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427561#M105477</guid>
      <dc:creator>Hemanth003</dc:creator>
      <dc:date>2018-01-14T22:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: #Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427562#M105478</link>
      <description>&lt;P&gt;I'm afraid I can't open attachments. Can you please paste as text&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 22:16:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427562#M105478</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-14T22:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: #Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427563#M105479</link>
      <description>&lt;P&gt;type wheelbase Length Money VendorMoney&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Hybrid&lt;/TD&gt;&lt;TD&gt;103&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;TD&gt;18025&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hybrid&lt;/TD&gt;&lt;TD&gt;95&lt;/TD&gt;&lt;TD&gt;55&lt;/TD&gt;&lt;TD&gt;5225&lt;/TD&gt;&lt;TD&gt;18025&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hybrid&lt;/TD&gt;&lt;TD&gt;106&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;TD&gt;18550&lt;/TD&gt;&lt;TD&gt;23250&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SUV&lt;/TD&gt;&lt;TD&gt;106&lt;/TD&gt;&lt;TD&gt;189&lt;/TD&gt;&lt;TD&gt;20034&lt;/TD&gt;&lt;TD&gt;41800&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SUV&lt;/TD&gt;&lt;TD&gt;110&lt;/TD&gt;&lt;TD&gt;180&lt;/TD&gt;&lt;TD&gt;19800&lt;/TD&gt;&lt;TD&gt;20034&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SUV&lt;/TD&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;184&lt;/TD&gt;&lt;TD&gt;20424&lt;/TD&gt;&lt;TD&gt;39834&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;HR /&gt;&lt;DIV class="systitleandfootercontainer"&gt;&lt;P&gt;&lt;SPAN class="c systemtitle"&gt;Vendor Totals: Dollars Spent and Bookings by Vendor&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;type wheelbase Length Money VendorMoney&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Hybrid&lt;/TD&gt;&lt;TD&gt;103&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;TD&gt;18025&lt;/TD&gt;&lt;TD&gt;18025&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hybrid&lt;/TD&gt;&lt;TD&gt;95&lt;/TD&gt;&lt;TD&gt;55&lt;/TD&gt;&lt;TD&gt;5225&lt;/TD&gt;&lt;TD&gt;23250&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hybrid&lt;/TD&gt;&lt;TD&gt;106&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;TD&gt;18550&lt;/TD&gt;&lt;TD&gt;41800&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SUV&lt;/TD&gt;&lt;TD&gt;106&lt;/TD&gt;&lt;TD&gt;189&lt;/TD&gt;&lt;TD&gt;20034&lt;/TD&gt;&lt;TD&gt;20034&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SUV&lt;/TD&gt;&lt;TD&gt;110&lt;/TD&gt;&lt;TD&gt;180&lt;/TD&gt;&lt;TD&gt;19800&lt;/TD&gt;&lt;TD&gt;39834&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SUV&lt;/TD&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;184&lt;/TD&gt;&lt;TD&gt;20424&lt;/TD&gt;&lt;TD&gt;60258&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I meant about the vendormoney column in both the tables!!!&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 22:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427563#M105479</guid>
      <dc:creator>Hemanth003</dc:creator>
      <dc:date>2018-01-14T22:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: #Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427566#M105481</link>
      <description>&lt;P&gt;OK,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here you go-:&lt;/P&gt;&lt;P&gt;1. At compile time, SAS reads the descriptive portion of the input dataset(cars) and builds the PDV. So you have all your variable names from your input dataset and your variables that is created&amp;nbsp; in the program as assignment statements and initializes with a value of missing. However in this case, since Vendormoney's assignment is on sum statement, the initial assignment is a zero instead of missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. At execution time or while execution happens, take your first obs from cars SAS read the values and starts processing. However your explicit output (output tourdetails; ) writes the obs to the output dataset&lt;SPAN&gt;tourdetails even before calculating&amp;nbsp;Vendormoney with its existing value that is zero.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. However the output&amp;nbsp;vendordetails statement does not execute before the sum statement, therefore you do not have zero.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In essence statements are executed sequentially, unless you use goto, return, link et al statements. Hope that helps&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 22:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427566#M105481</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-14T22:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: #Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427568#M105483</link>
      <description>&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;'s explanation but, given your code, VendorMoney won't even be in tourdetails since you drop that variable in your code. Also, you create sortcars in your proc sort step, but then set sortcar in your datastep. Obviously, the output you posted was not from the code you posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 22:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427568#M105483</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-01-14T22:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: #Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427569#M105484</link>
      <description>&lt;P&gt;I am sorry I should have removed those commands and should have posted.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 22:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427569#M105484</guid>
      <dc:creator>Hemanth003</dc:creator>
      <dc:date>2018-01-14T22:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: #Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427581#M105494</link>
      <description>&lt;P&gt;Thank you!! That was very helpful:)&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 23:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427581#M105494</guid>
      <dc:creator>Hemanth003</dc:creator>
      <dc:date>2018-01-14T23:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: #Doubt regarding the flow of the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427583#M105496</link>
      <description>&lt;P&gt;You really should change the correct solution to the response provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;. I was simply pointing out the inconsistency in your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&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;</description>
      <pubDate>Sun, 14 Jan 2018 23:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Doubt-regarding-the-flow-of-the-code/m-p/427583#M105496</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-01-14T23:54:30Z</dc:date>
    </item>
  </channel>
</rss>

