<?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: Montecarlo Simulations in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965572#M2667</link>
    <description>&lt;P&gt;Thank you for the response. The issue is not getting resolved. Further, i am trying to learn and its not for assignment. If anyone willing to help then i can email the dataset and coding script.&amp;nbsp; My questions is very simple that i wanted to have&amp;nbsp; 10 random values for each row scnerio but i am getting the same result.&amp;nbsp; I have given code above, if anybody can competely amend the code and paste below, will be thankful.&lt;/P&gt;</description>
    <pubDate>Fri, 02 May 2025 03:27:53 GMT</pubDate>
    <dc:creator>skumar46</dc:creator>
    <dc:date>2025-05-02T03:27:53Z</dc:date>
    <item>
      <title>Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965343#M2649</link>
      <description>&lt;DIV&gt;Dear All&lt;/DIV&gt;&lt;DIV&gt;I wanted to run&amp;nbsp;Monte Carlo Simulation - Run 10 Iterations but dont know that why its giving me the same out for all 10 itertaions (output attached). I have used chatgpt &amp;amp; deepseek but its of no support. I have attached dataset as well as sas coding script. Would appreciate support by pasting code completely or answering me after checking 1st that its working in sas on demand. Thank you&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/* Step 4: Monte Carlo Simulation - Run 10 Iterations for Random Loss Outcomes */&lt;/DIV&gt;&lt;DIV&gt;data montecarlo;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;set portfolio_sim;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;do sim_id = 1 to 10;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;/* Introduce random variation to PD and LGD */&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;random_PD = rand("NORMAL", Sim_PD, 0.01);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;random_LGD = rand("NORMAL", Sim_LGD, 0.05);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;random_PD = max(0, min(random_PD, 1));&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;random_LGD = max(0, min(random_LGD, 1));&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sim_loss = random_PD * random_LGD * EAD * Current_Balance;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;output;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;end;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;OR&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data montecarlo;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; set portfolio_sim;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; /* Convert alphanumeric Borrower_ID to numeric seed */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; numeric_id = input(compress(Borrower_ID, , 'kd'), 8.);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; do sim_id = 1 to 10;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Create unique seed for each borrower-simulation combination */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; seed = numeric_id * 100 + sim_id;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; call streaminit(seed);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Generate random values */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; random_PD = rand("NORMAL", Sim_PD, 0.01);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; random_LGD = rand("NORMAL", Sim_LGD, 0.05);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Constrain to valid ranges */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; random_PD = max(0, min(random_PD, 1));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; random_LGD = max(0, min(random_LGD, 1));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Calculate loss */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sim_loss = random_PD * random_LGD * EAD * Current_Balance;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; drop numeric_id seed; /* Clean up temporary variables */&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 07:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965343#M2649</guid>
      <dc:creator>skumar46</dc:creator>
      <dc:date>2025-04-29T07:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965347#M2650</link>
      <description>&lt;P&gt;First, most of us will not download Microsoft Office attachments, they can&amp;nbsp; be security threats. I personally will not download any attachment. If you want us to see something, paste it into your message rather than attaching a file. If you want to provide us with a SAS data set, please follow these &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions and examples&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, code should be pasted into the "code box", which is the window that appears when you click on the "little running man" icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your problem of why all of this random numbers generates a constant results is that you have these lines in your code (see I have pasted the code into the code box)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;random_PD = max(0, min(random_PD, 1));
random_LGD = max(0, min(random_LGD, 1));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the lines before, you randomly generate random_PD and random_LGD. The minimum of your random_PD and 1 is always 1, so that's what you get. Similarly, the minimum of random_LGD and 1 is always 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you want to use the uniform distribution, which can force the randomly generated numbers to the range 0 and 1, and no need to adjust them further to be between 0 and 1. That's a guess on my part, you didn't explain the problem you are working on (which you should always do), and then we would understand what you are trying to do and we wouldn't have to guess (which is never a good thing for us to do).&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 12:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965347#M2650</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-04-29T12:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965394#M2656</link>
      <description>&lt;P&gt;You would need to provide the INPUT data set&amp;nbsp;Portfolio_sim to mean anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you are using SIM_id as the MEAN of the NORMAL distribution you will have most of your values of the result of the RAND calls close to 2, 3, 4 etc. So pretty much 9 out of 10 of those mean that min(random_PD, 1) are returning 1 so the max(0,1) are returning the 1. And only half of the Sim_id=1 even have a chance of returning a value less than 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then you overwrite the values of the random results so you cannot see that your original values are mostly way larger than 1. Modify these to create new variables to see why you get mostly 1's as results.&lt;/P&gt;
&lt;PRE&gt;      /* Constrain to valid ranges */
        random_PD = max(0, min(random_PD, 1));
        random_LGD = max(0, min(random_LGD, 1));&lt;/PRE&gt;
&lt;P&gt;Do you know what percentage of results of a call such as rand("NORMAL", Sim_PD, 0.01) will have a result withing +/- 0.02 difference from Sim_PD? &lt;/P&gt;
&lt;P&gt;Until you understand what the standard deviation is doing to those calls to rand('Normal') (do note the default for Normal is an SD=1) you should be very careful specifying it. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or better yet, describe what sort of result you expect to be returning as I thing &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; is on track.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 21:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965394#M2656</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-04-29T21:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965400#M2657</link>
      <description>&lt;P&gt;Sir, Its not working. I would appreciate if you provide me/paste the complete code here. I want 10&amp;nbsp; 10 iterations with different result for PD, LGD, expected loss? OR how would you prepare code for&amp;nbsp;Montecarlo Simulations? I can connect on&amp;nbsp; zoom or teams if you want to support?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 23:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965400#M2657</guid>
      <dc:creator>skumar46</dc:creator>
      <dc:date>2025-04-29T23:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965413#M2658</link>
      <description>&lt;P&gt;There have been many suggestions in this thread, but you have provided no additional information about what you tried. What did you try? Show us the code. What happened? If there are errors in the log, please show us the log. If the results are wrong, show us the results and explain why you think these are incorrect. Please provide information! Remember, do not attach files.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2025 10:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965413#M2658</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-04-30T10:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965414#M2659</link>
      <description>&lt;P&gt;Also note that this&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466779"&gt;@skumar46&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV&gt;&lt;SPAN&gt;(...)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; do sim_id = 1 to 10;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Create unique seed for each borrower-simulation combination */&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; seed = numeric_id * 100 + sim_id;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; call streaminit(seed);&lt;/DIV&gt;
&lt;P&gt;(...)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;does &lt;EM&gt;not&lt;/EM&gt; achieve what you intend. Only the first call of the STREAMINIT routine in a DATA step takes effect. (See the "Tip" in the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0gw58qo85qp56n1kbpiz50ww8lv.htm#p1gpvz37dr3xesn188v8dy29jpf2" target="_blank" rel="noopener"&gt;description of parameter &lt;EM&gt;&lt;STRONG&gt;seed&lt;/STRONG&gt;&amp;nbsp;&lt;/EM&gt; in the documentation of CALL STREAMINIT&lt;/A&gt;.) Hence, only the first created &lt;FONT face="courier new,courier"&gt;seed&lt;/FONT&gt; value is actually used. If the first value of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;numeric_id&lt;/FONT&gt; is, say, 123, you will obtain the same result as with a single&lt;/P&gt;
&lt;PRE&gt;call streaminit(12301);&lt;/PRE&gt;
&lt;P&gt;at the beginning of the DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look into the documentation of &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0lbmkanxprdm3n1wvwmp15oxwvy.htm" target="_blank" rel="noopener"&gt;CALL STREAM&lt;/A&gt; if you really need more control over the random number streams used. For example, you could use separate random number streams for each borrower:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#808080"&gt;data want;
&lt;FONT color="#000000"&gt;&lt;STRONG&gt;call streaminit(27182818);&lt;/STRONG&gt;&lt;/FONT&gt;
  set portfolio_sim;
  /* Convert alphanumeric Borrower_ID to numeric key */
  numeric_id = input(compress(Borrower_ID, , 'kd'), 8.);
  /* Use a separate random number stream for each borrower */
  &lt;FONT color="#000000"&gt;&lt;STRONG&gt;call stream(numeric_id);&lt;/STRONG&gt;&lt;/FONT&gt;    
  do sim_id = 1 to 10;
    /* Generate random values */
    random_PD = rand("NORMAL", Sim_PD, 0.01);
    ...
&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;This would enable you to reproduce the simulated data for any given &lt;FONT face="courier new,courier"&gt;Borrower_ID&lt;/FONT&gt; in a later DATA step by just specifying the same combination of seed (here: &lt;FONT face="courier new,courier"&gt;27182818&lt;/FONT&gt;) and key (here: &lt;FONT face="courier new,courier"&gt;numeric_id&lt;/FONT&gt;) values. It also includes the possibility of increasing the number of simulations (e.g., &lt;FONT face="courier new,courier"&gt;do sim_id = 1 to &lt;STRONG&gt;15&lt;/STRONG&gt;;&lt;/FONT&gt;) without changing the results for &lt;FONT face="courier new,courier"&gt;sim_id=1&lt;/FONT&gt;, ..., &lt;FONT face="courier new,courier"&gt;10&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2025 11:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965414#M2659</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-04-30T11:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965469#M2660</link>
      <description>&lt;P&gt;Sir, I appreciate you taking time to response. I am basic sas user and trying to learn with the help of chatgpt &amp;amp; deepseek neither i couldnt find solution there nor i am able to catch you. I would request you to review my codes in intitial enquiry and then just provide your complete code which should be workable by pasting in sas on demand then i will be able to check and share with you the logs as such i am not able to co-related your points. Pls paste here code/(s) starting from 1st line of code and run; word.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2025 23:42:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965469#M2660</guid>
      <dc:creator>skumar46</dc:creator>
      <dc:date>2025-04-30T23:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965472#M2661</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466779"&gt;@skumar46&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sir, I appreciate you taking time to response. I am basic sas user and trying to learn with the help of chatgpt &amp;amp; deepseek neither i couldnt find solution there nor i am able to catch you. I would request you to review my codes in intitial enquiry and then just provide your complete code which should be workable by pasting in sas on demand then i will be able to check and share with you the logs as such i am not able to co-related your points. Pls paste here code/(s) starting from 1st line of code and run; word.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Strongly suggest you add a lot of description to what you are attempting. For example, why are you using the loop counter Sim_id as the MEAN of a normal distribution? Why are you trimming the values? Why did you overwrite the original values of the RAND calls with those min/max function results?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I repeat, that since you are using an input data set that you provide an example of that set as working data step code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do also note that SAS offers a free introductory programming course. &lt;/P&gt;
&lt;P&gt;I cringe at the idea of trying to learn from Chatgpt generated code considering some of that code that has appeared on this forum. One example had something like 6 syntax violations in the first 8 lines. &lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2025 03:04:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965472#M2661</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-05-01T03:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965483#M2662</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466779"&gt;@skumar46&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV&gt;I wanted to run&amp;nbsp;... 10 Iterations but dont know that why its giving me the same out for all 10 itertaions (output attached).&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your output shows 10 out of 15,000 observations and only 4 out of 33 variables, whose (possibly formatted) values are constant on those 10 observations. None of these variables (&lt;FONT face="courier new,courier"&gt;Scenario&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;Sim_PD&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;Sim_LGD&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;Expected_Loss&lt;/FONT&gt;) is created in either of the two DATA steps that you posted. Hence, these variables must be contained in the input dataset PORTFOLIO_SIM. Their values are read by the SET statement, left unchanged by the other DATA step statements and written to the output dataset MONTECARLO by the OUTPUT statement. As this occurs in a DO loop with 10 iterations (&lt;FONT face="courier new,courier"&gt;do sim_id = 1 to 10;&lt;/FONT&gt;), those four variable values are &lt;EM&gt;necessarily&lt;/EM&gt; the same in all 10 observations created from one observation of PORTFOLIO_SIM. They are just copies of the original values from the input dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you observed variable values that are equal &lt;EM&gt;contrary to expectations&lt;/EM&gt; (e.g., values created by the RAND function calls in your code), then please show us.&lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2025 08:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965483#M2662</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-05-01T08:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965484#M2663</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466779"&gt;@skumar46&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sir, I appreciate you taking time to response. I am basic sas user and trying to learn with the help of chatgpt &amp;amp; deepseek neither i couldnt find solution there nor i am able to catch you. I would request you to review my codes in intitial enquiry and then just provide your complete code which should be workable by pasting in sas on demand then i will be able to check and share with you the logs as such i am not able to co-related your points. Pls paste here code/(s) starting from 1st line of code and run; word.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We have asked you for additional information. You have not provided that information, so we can't help. (and unlikely AI chatbots will be able to guide you when you have errors in your programming)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;People have provided suggestions about what you can try to fix the problem. Have you tried them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, our job here is to help you with SAS problems and help you learn certain aspects of SAS, but as stated we need information. Our job is not to do your assignments for you, which seems like what you are asking.&lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2025 11:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965484#M2663</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-05-01T11:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965572#M2667</link>
      <description>&lt;P&gt;Thank you for the response. The issue is not getting resolved. Further, i am trying to learn and its not for assignment. If anyone willing to help then i can email the dataset and coding script.&amp;nbsp; My questions is very simple that i wanted to have&amp;nbsp; 10 random values for each row scnerio but i am getting the same result.&amp;nbsp; I have given code above, if anybody can competely amend the code and paste below, will be thankful.&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 03:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965572#M2667</guid>
      <dc:creator>skumar46</dc:creator>
      <dc:date>2025-05-02T03:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965583#M2668</link>
      <description>&lt;P&gt;In your initial post you wrote&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV&gt;&lt;SPAN&gt;(...) I have attached dataset&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But there is no dataset attached. So let me create test data using some of the values shown in the partial output that you did attach.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data portfolio_sim;
input Borrower_ID $ Sim_PD Sim_LGD EAD Current_Balance;
cards;
B0001 0.2905 0.638 2 500
B0002 2.905  6.38  2 500
B0003 0.2905 0.638 2 500
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you run either of your two DATA steps on the above test data, you will see&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;for &lt;FONT face="courier new,courier"&gt;Borrower_ID&lt;/FONT&gt; B0001 and B0003: trivially constant values of &lt;FONT face="courier new,courier"&gt;Sim_PD&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;Sim_LGD&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;EAD&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;Current_Balance&lt;/FONT&gt;&amp;nbsp;(as explained in my previous post), but randomly varying values of &lt;FONT face="courier new,courier"&gt;random_PD&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;random_LGD&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;sim_loss&lt;/FONT&gt;&amp;nbsp;which differ between B0001 and B0003 (although the values of &lt;FONT face="courier new,courier"&gt;Sim_PD&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;Sim_LGD&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;EAD&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;Current_Balance&lt;/FONT&gt;&amp;nbsp;are the same for both borrower IDs)&lt;/LI&gt;
&lt;LI&gt;for &lt;FONT face="courier new,courier"&gt;Borrower_ID&lt;/FONT&gt; B0002: constant values also of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;random_PD&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;random_LGD&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;sim_loss&lt;/FONT&gt;&amp;nbsp;because all the initial random values of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;random_PD&lt;/FONT&gt; and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;random_LGD&lt;/FONT&gt; were greater than 1 and therefore replaced with 1 by the assignment statements with the comment "Constrain to valid ranges" (as pointed out in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;'s first reply).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466779"&gt;@skumar46&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i am getting the same result.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Again, i&lt;SPAN&gt;f you observed variable values that are "the same"&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;contrary to expectations&lt;/EM&gt;&lt;SPAN&gt;, then please show us.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 08:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965583#M2668</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-05-02T08:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965630#M2670</link>
      <description>&lt;P&gt;Thank you for the reply. I have attached the dataset and sas coding script. There are 500 ids i.e&amp;nbsp;&lt;STRONG&gt;B00000 to&amp;nbsp;B00499.&amp;nbsp; Pls help me with&amp;nbsp;Montecarlo Simulations i.e having 10 different random values for PG, LGD&amp;nbsp; i.e there will be 10 different rows for each borrower id like&amp;nbsp;B00000&amp;nbsp; showing different PG, LGD values.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I am not doing any assignment but trying to learn. OR based on attached datset , how would you do&amp;nbsp;Montecarlo Simulations looping PG, LGD 10 times so that we have random values?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 May 2025 01:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965630#M2670</guid>
      <dc:creator>skumar46</dc:creator>
      <dc:date>2025-05-03T01:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965649#M2672</link>
      <description>&lt;P&gt;It looks like you work with Excel data&amp;nbsp;on a regular basis so that you think of an .xlsx-file as a dataset. This is good because I can assume that you know how to read your attached Excel table into a SAS dataset named&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;portfolio_sim&lt;/FONT&gt;. (I don't have Excel installed on my SAS workstation, nor is the SAS/ACCESS Interface to PC Files part of my SAS license, so I can't work with .xlsx data directly.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then you can slightly adapt the beginning of the first DATA step (called "Step 4" in a comment) from your initial post as follows&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#999999"&gt;data montecarlo&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;(rename=(random_PD=PD random_LGD=LGD Sim_PD=original_PD Sim_LGD=original_LGD))&lt;/STRONG&gt;&lt;/FONT&gt;;
&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;call streaminit(1);&lt;/STRONG&gt;&lt;/FONT&gt;
set portfolio_sim&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;(rename=(PD=Sim_PD LGD=Sim_LGD))&lt;/STRONG&gt;&lt;/FONT&gt;;
...&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;and run the DATA step on the newly created dataset &lt;FONT face="courier new,courier"&gt;portfolio_sim&lt;/FONT&gt;. The resulting output dataset &lt;FONT face="courier new,courier"&gt;montecarlo&lt;/FONT&gt; should contain 5000 observations: 10 per borrower ID, with randomly varying PD and LGD values, as desired. (The "constraining to valid ranges" will likely be applied to only very few values and should not be a problem for learning purposes.)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 03 May 2025 11:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965649#M2672</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-05-03T11:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965722#M2673</link>
      <description>&lt;P&gt;Thank you for taking time to help me out but its not going through. If you are from Sas team, can we connect through zoom/ teams?&lt;/P&gt;&lt;P&gt;yes, data is read correctly in sas on demad. I understand that you wanted me to modiy the step # 4 of code and i modified in diff ways but its not working. I believe its wasting both of our time probably because i am basic user so wanted to reach out for the last time. Providing a incomplete code creating confusuin for me as such i am not good in connecting the things etc. this is pretty advanced topic me but i am trying to learn.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that you are unable to download excel dataset. So, for your ease, i am pasting datasnapshot in msword, along code script details. I want you to share complete code for step # 4 rather than 2-3 lines which helps me working the code by pasting;-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if couldnt get the complete code for step # 4 /not working after this , then i would go for closure of this unsolved.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 04:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965722#M2673</guid>
      <dc:creator>skumar46</dc:creator>
      <dc:date>2025-05-05T04:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965734#M2674</link>
      <description>&lt;P&gt;Thanks for providing more complete information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On page 3 of your Word document (which I read using the document preview feature of the forum as no MS Word is installed on my SAS workstation) you show a DATA step that you say is "not working with the purpose". However, if I run this and the two preceding steps using a simplified version of your LOANS dataset, it appears to work perfectly: It creates 10 observations for each Borrower_ID-Scenario combination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the first three observations for borrower ID B00000 in the "Adverse" scenario (i.e., observations 11 through 13 of the output dataset MONTECARLO), limited to the most important variables:&lt;/P&gt;
&lt;PRE&gt;Borrower_                                                                 random_    random_
   ID        Scenario      PD       LGD    Sim_PD    Sim_LGD    sim_id       PD        LGD      sim_loss

 B00000      Adverse     0.2324    0.58    0.2905     0.638        1      0.29511    0.70829     5596.03
 B00000      Adverse     0.2324    0.58    0.2905     0.638        2      0.28944    0.59881     4640.23
 B00000      Adverse     0.2324    0.58    0.2905     0.638        3      0.29920    0.64346     5154.29&lt;/PRE&gt;
&lt;P&gt;Variables PD and LGD are copied from the LOANS dataset, Sim_PD and Sim_LGD were created in your PROC SQL step. In the DO loop of the final DATA step (&lt;FONT face="courier new,courier"&gt;do sim_id = 1 to 10;&lt;/FONT&gt;) the randomly varying values of random_PD and random_LGD were generated and used in the calculation of sim_loss. (My suggested renaming of variables would have applied to a PORTFOLIO_SIM dataset using the variable names from the LOANS dataset, which turned out to be different datasets, so no renaming is necessary.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, while the first six of the variables shown above have &lt;EM&gt;necessarily&lt;/EM&gt; the same values in these three observations, the newly computed last three variables exhibit the random variation to be expected from a Monte Carlo simulation. Why do you think that these results are not suitable for your purposes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466779"&gt;@skumar46&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If you are from Sas team, can we connect through zoom/ teams?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, I am not affiliated with SAS Institute Inc. Like most of the other forum members I am a volunteer,&amp;nbsp;just another SAS user like you (with 27 years of SAS experience, though), helping others in parallel to my actual work.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 09:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965734#M2674</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-05-05T09:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965792#M2675</link>
      <description>&lt;P&gt;Thank you so much for prompt response. I am happy to see that you have got my questions well and will be getting 100% solution soon. Please refer to the following mentioned by you quoted by me below. With the code # 4 titled "/* Step 4: Monte Carlo Simulation - Run 10 Iterations for Random Loss Outcomes */" in my coding script whose result/output pasted in attached ms word. You can see that for&amp;nbsp;&lt;FONT face="courier new,courier"&gt;sim_id = 1 to 10, for the borrower id :B0000 under baselines scenerio, i am getting same result for sim_PD= 0.2324, sim_&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;LGD = 0.58, exp loss: 3,608.73 for all sim_id from 1 to 10, why these are not changing. Now, i understand that like you added three last columnns i.e random_PD random_LGD &amp;amp; sim_loss but that not fetched by sas on demand when i run this in sam on demand. I dont know what issue i am facing ? Are you using also sas on demand? If you changed step# 4 little bit then pls share code with me please here.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quote&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;"In the DO loop of the final DATA step (&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;do sim_id = 1 to 10;&lt;/FONT&gt;&lt;SPAN&gt;) the randomly varying values of random_PD and random_LGD were generated and used in the calculation of sim_loss"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 17:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965792#M2675</guid>
      <dc:creator>skumar46</dc:creator>
      <dc:date>2025-05-05T17:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965817#M2676</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466779"&gt;@skumar46&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;(...)&amp;nbsp;&lt;FONT face="courier new,courier"&gt;for the borrower id :B0000 under baselines scenerio, i am getting same result for sim_PD= 0.2324, sim_&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;LGD = 0.58, exp loss: 3,608.73 for all sim_id from 1 to 10, why these are not changing.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is because these three variables&amp;nbsp;&lt;SPAN&gt;were created in your PROC SQL step: Look at the first occurrences of their names in your code. Sim_PD and Sim_LGD are derived from PD and LGD, respectively, in CASE-WHEN expressions. Expected_Loss is the result of a multiplication involving Sim_PD, Sim_LGD and two other factors.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the final DATA step, Sim_PD and Sim_LGD are used as &lt;EM&gt;arguments&lt;/EM&gt; of the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0fpeei0opypg8n1b06qe4r040lv.htm" target="_blank" rel="noopener"&gt;RAND function&lt;/A&gt;, which does not change their values. Instead, the randomly changing values &lt;EM&gt;returned&lt;/EM&gt; by this function are stored in variables named random_PD and random_LGD. These, in turn, are used in the calculation of variable sim_loss.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As a result, the only variables that have a chance to differ between observations in dataset MONTECARLO with the same Borrower_ID and Scenario are: random_PD, random_LGD, sim_loss and (trivially) sim_id.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;All other variables just contribute 10 copies (per Borrower_ID-Scenario combination) of their corresponding value in dataset PORTFOLIO_SIM.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466779"&gt;@skumar46&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Now, i understand that like you added three last columnns i.e random_PD random_LGD &amp;amp; sim_loss but that not fetched by sas on demand when i run this in sam on demand.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;These variables &lt;EM&gt;must&lt;/EM&gt; be contained in dataset MONTECARLO if the DATA step creating it ran successfully. You may need to scroll your output to the rightmost columns to make them visible in the window. Or use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1cfqafrw9xvoln1sz5oed59lyf3.htm" target="_blank" rel="noopener"&gt;VAR statement&lt;/A&gt; of PROC PRINT to select and order the most important variables to be displayed in the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=montecarlo(obs=10);
&lt;STRONG&gt;var Borrower_ID Scenario sim_id random_PD random_LGD sim_loss;&lt;/STRONG&gt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466779"&gt;@skumar46&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Are you using also sas on demand?&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, I have never used SAS OnDemand because I have always used SAS software provided by my employers or clients and, since 2015, my own local SAS installation.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 19:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965817#M2676</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-05-05T19:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965819#M2677</link>
      <description>&lt;P&gt;Thank you so much for all your time to reply my queries patiently. I understand that i need to do a lot of&amp;nbsp; pratcice for improving my basic.&amp;nbsp; While i am able to view the random values for PG &amp;amp; LGD but dont undersrand that why values i am getting differ from the 3 rows shared in your reply.&amp;nbsp; Pls refer last page of ms word.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it because that these randoms values will be different each type i run the code because of random nature like you and me getting different values?&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 19:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965819#M2677</guid>
      <dc:creator>skumar46</dc:creator>
      <dc:date>2025-05-05T19:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Montecarlo Simulations</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965825#M2678</link>
      <description>&lt;P&gt;You're welcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The (pseudo-)random values of random_PD and random_LGD created by the RAND function depend on the random seed used in the CALL STREAMINIT routine (the value 1 in our code), the random-number generator (&lt;SPAN&gt;MTHybrid is the default, but only since SAS 9.4M3),&amp;nbsp;&lt;/SPAN&gt;the order in which they are calculated and possibly even on the platform (hardware and operating system).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In our case the order of calculations might be the reason why we get different results. For example, if scenario "Adverse" came before "Baseline" in dataset PORTFOLIO_SIM, the random values for "Adverse" would be different from what they are with "Baseline" being the first scenario. The sort order of the borrower IDs is similarly important. Note that since PORTFOLIO_SIM was created by PROC SQL without an ORDER BY clause, the order of observations in&amp;nbsp;PORTFOLIO_SIM can be different on different computers, even using the same program code!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have just created one million pairs of random_PD and random_LGD values based on the Sim_PD and Sim_LGD values of the case in question and I found your values in observations 3901, 3902, ..., 3910 of this series. So, maybe 3900 other values had been created before due to sort order differences or other technical reasons (consider perhaps multi-threaded parallel computing on the server SAS OnDemand connects to).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a matter of fact, you don't have to worry about those differences. Your values are valid and it is reassuring that I could reproduce them on my computer.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 21:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Montecarlo-Simulations/m-p/965825#M2678</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-05-05T21:09:23Z</dc:date>
    </item>
  </channel>
</rss>

