<?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 Random sampling of n=500 by a random year btw. 1999 and 2022. Am I doing correct? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Random-sampling-of-n-500-by-a-random-year-btw-1999-and-2022-Am-I/m-p/908534#M358527</link>
    <description>&lt;P&gt;Hi, greetings, My SAS community!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been helped so much by the Community. Even though I find no ways to directly return my thanks, I always cherish my thanks to you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a kind of annual firm financial data (panel) over 1999~2022.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on this data set, I want to pick a random year between 1999 and 2022, fifty times. Each time, I want to further random-sample 500 obs. prior to 1 + the year randomly picked. Below are the SAS codes I created:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro simul(rep=);
%do i=1 %to &amp;amp;rep;
DATA Compustat_6; SET Compustat_5; yr=rand('integer',1999,2022); run; 
DATA Survivors; SET Compustat_6; if fyear&amp;lt;yr+1; RUN; 
proc surveyselect data=Survivors method=srs rep=1 sampsize = 500 seed = 12345 out=Reg_surv; id _all_; run; 
proc reg data= Reg_surv outest=result_reg_surv noprint; 
model Tobinq = roa blev; run; 
proc append base= final_reg_surv data= result_reg_surv force;
%end;
%mend;
%simul(rep=50);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have three questions about the results:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(1) The dataset&amp;nbsp;&lt;CODE class=" language-sas"&gt;result_reg_surv&lt;/CODE&gt;&amp;nbsp; shows the intercept, coefficients of roa and blev. But I want to add standard error or t-values for the dependent variables, as well as their confidence intervals from each regression. What options should I enter where?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(2) I want to append the simulated regression results onto the dataset&amp;nbsp;&lt;CODE class=" language-sas"&gt;final_reg_surv&lt;/CODE&gt;&amp;nbsp;iteratively. But SAS reports an error message that the variables Intercept, roa, and blev are not found in&amp;nbsp;&lt;CODE class=" language-sas"&gt;final_reg_surv&lt;/CODE&gt;&amp;nbsp;. What's wrong with my coding?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(3) After I executed the codes, I opened the dataset&amp;nbsp;&lt;CODE class=" language-sas"&gt;Reg_surv&lt;/CODE&gt;&amp;nbsp;to check the data on which the 50th regression was made. As I checked the variable yr, yr comprises various years. What I expected was that yr should be a single year value from the last 50th&amp;nbsp;&lt;CODE class=" language-sas"&gt;yr=rand('integer',1999,2022)&lt;/CODE&gt;&amp;nbsp;random pick-up.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should I fix these problems based on the codes I created?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance, happy X-mas!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sincerely,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;KS -&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;</description>
    <pubDate>Mon, 18 Dec 2023 02:16:37 GMT</pubDate>
    <dc:creator>KS99</dc:creator>
    <dc:date>2023-12-18T02:16:37Z</dc:date>
    <item>
      <title>Random sampling of n=500 by a random year btw. 1999 and 2022. Am I doing correct?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-sampling-of-n-500-by-a-random-year-btw-1999-and-2022-Am-I/m-p/908534#M358527</link>
      <description>&lt;P&gt;Hi, greetings, My SAS community!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been helped so much by the Community. Even though I find no ways to directly return my thanks, I always cherish my thanks to you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a kind of annual firm financial data (panel) over 1999~2022.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on this data set, I want to pick a random year between 1999 and 2022, fifty times. Each time, I want to further random-sample 500 obs. prior to 1 + the year randomly picked. Below are the SAS codes I created:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro simul(rep=);
%do i=1 %to &amp;amp;rep;
DATA Compustat_6; SET Compustat_5; yr=rand('integer',1999,2022); run; 
DATA Survivors; SET Compustat_6; if fyear&amp;lt;yr+1; RUN; 
proc surveyselect data=Survivors method=srs rep=1 sampsize = 500 seed = 12345 out=Reg_surv; id _all_; run; 
proc reg data= Reg_surv outest=result_reg_surv noprint; 
model Tobinq = roa blev; run; 
proc append base= final_reg_surv data= result_reg_surv force;
%end;
%mend;
%simul(rep=50);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have three questions about the results:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(1) The dataset&amp;nbsp;&lt;CODE class=" language-sas"&gt;result_reg_surv&lt;/CODE&gt;&amp;nbsp; shows the intercept, coefficients of roa and blev. But I want to add standard error or t-values for the dependent variables, as well as their confidence intervals from each regression. What options should I enter where?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(2) I want to append the simulated regression results onto the dataset&amp;nbsp;&lt;CODE class=" language-sas"&gt;final_reg_surv&lt;/CODE&gt;&amp;nbsp;iteratively. But SAS reports an error message that the variables Intercept, roa, and blev are not found in&amp;nbsp;&lt;CODE class=" language-sas"&gt;final_reg_surv&lt;/CODE&gt;&amp;nbsp;. What's wrong with my coding?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(3) After I executed the codes, I opened the dataset&amp;nbsp;&lt;CODE class=" language-sas"&gt;Reg_surv&lt;/CODE&gt;&amp;nbsp;to check the data on which the 50th regression was made. As I checked the variable yr, yr comprises various years. What I expected was that yr should be a single year value from the last 50th&amp;nbsp;&lt;CODE class=" language-sas"&gt;yr=rand('integer',1999,2022)&lt;/CODE&gt;&amp;nbsp;random pick-up.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should I fix these problems based on the codes I created?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance, happy X-mas!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sincerely,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;KS -&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;</description>
      <pubDate>Mon, 18 Dec 2023 02:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-sampling-of-n-500-by-a-random-year-btw-1999-and-2022-Am-I/m-p/908534#M358527</guid>
      <dc:creator>KS99</dc:creator>
      <dc:date>2023-12-18T02:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Random sampling of n=500 by a random year btw. 1999 and 2022. Am I doing correct?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-sampling-of-n-500-by-a-random-year-btw-1999-and-2022-Am-I/m-p/908540#M358530</link>
      <description>&lt;P&gt;For your first question :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods select none;
proc reg data=sashelp.class ;
model weight=age height/clb;
ods output  ParameterEstimates= result_reg_surv ;
quit;
ods select all;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your second question:&lt;/P&gt;
&lt;P&gt;1)It looks like there are some dataset you can not fit a model,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Is there any ERROR or WARNING information in LOG ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)I am not sure .But you need delete dataset "final_reg_surv " before invoking macro "%simul(rep=50);" .&amp;nbsp; Like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;.............
options nodsnferr;
proc delete data=final_reg_surv  ; run;
%simul(rep=50);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your third question:&lt;/P&gt;
&lt;P&gt;You could add an ID variable to mark the id number of iterative.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro simul(rep=);
%do i=1 %to &amp;amp;rep;
DATA Compustat_6; SET Compustat_5; yr=rand('integer',1999,2022); run; 
DATA Survivors; SET Compustat_6; if fyear&amp;lt;yr+1; RUN; 
proc surveyselect data=Survivors method=srs rep=1 sampsize = 500 seed = 12345 out=Reg_surv; id _all_; run; 
proc reg data= Reg_surv outest=result_reg_surv noprint; 
model Tobinq = roa blev; run; 

data result_reg_surv ;
 set result_reg_surv ;
 _id_=&amp;amp;i. ;
run;

proc append base= final_reg_surv data= result_reg_surv force;
%end;
%mend;
%simul(rep=50);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 06:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-sampling-of-n-500-by-a-random-year-btw-1999-and-2022-Am-I/m-p/908540#M358530</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-12-18T06:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Random sampling of n=500 by a random year btw. 1999 and 2022. Am I doing correct?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-sampling-of-n-500-by-a-random-year-btw-1999-and-2022-Am-I/m-p/909139#M358641</link>
      <description>&lt;P&gt;Hi, nice to see you again, K-Sharp!!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I opened your message and got your codes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I inserted them into my old codes after modifying them a little bit, and they work perfectly as I wanted them!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you, K-Sharp,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wish you great holidays!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;KS -&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2023 18:33:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-sampling-of-n-500-by-a-random-year-btw-1999-and-2022-Am-I/m-p/909139#M358641</guid>
      <dc:creator>KS99</dc:creator>
      <dc:date>2023-12-20T18:33:52Z</dc:date>
    </item>
  </channel>
</rss>

