<?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 use a  Do loop when the code is a  mixed between Proc/IML and other SAS/STAT in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550853#M4643</link>
    <description>&lt;P&gt;&amp;nbsp;That may work. Thanks!&lt;/P&gt;</description>
    <pubDate>Sat, 13 Apr 2019 19:30:48 GMT</pubDate>
    <dc:creator>Salah</dc:creator>
    <dc:date>2019-04-13T19:30:48Z</dc:date>
    <item>
      <title>How to use a  Do loop when the code is a  mixed between Proc/IML and other SAS/STAT</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550827#M4638</link>
      <description>&lt;P&gt;I have a code that contains parts from SAS/STAT and parts from Proc/IML.&lt;/P&gt;&lt;P&gt;The code censors data then calculate the area.&lt;/P&gt;&lt;P&gt;The censoring is done first for 500 observations then goes up to 5000 observations with increment of 500.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help in how to write the loop in this case. I am using SAS 9.4&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2019 04:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550827#M4638</guid>
      <dc:creator>Salah</dc:creator>
      <dc:date>2019-04-13T04:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a  Do loop when the code is a  mixed between Proc/IML and other SAS/STAT</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550839#M4639</link>
      <description>&lt;P&gt;I do not fully understand your problem, but do the various samples build on each other? Can you read in the final 5000 observations and then analyze the first 500, the first 1000, the first 1500, etc?&amp;nbsp; (or maybe you are analyzing (1:500, 501:1000, ...? It's not clear.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, here is the basic structure for subsetting the data. I assume you want to analyze 1:500, 1:1000, 1:1500, etc, but the program can be modified to&amp;nbsp; other situations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc iml;
start TrapIntegral(x,y);
   N = nrow(x);
   dx = x[2:N] - x[1:N-1];
   meanY = ( y[2:N] + y[1:N-1] )/2;
return( dx` * meanY );
finish;

grid = T( do(-5+0.002, 5, 0.002) );
density = pdf("Normal", grid);     /* N(0,1) density on [-5, 5] */
N = nrow(density);
print N;

sizes = T( do(500, N, 500) );       
Area = j(nrow(sizes), 1, .);
do i = 1 to nrow(sizes);
   obsIdx = 1:sizes[i]; /* or sizes[i-1]:sizes[i] ? */
   x = grid[obsIdx];    /* subset the data */
   y = density[obsIdx]; 
   Area[i] = TrapIntegral(x, y);
end;

print sizes Area;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Apr 2019 10:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550839#M4639</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-04-13T10:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a  Do loop when the code is a  mixed between Proc/IML and other SAS/STAT</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550840#M4640</link>
      <description>&lt;P&gt;You will need a macro %DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dothis;
    %do start = 1 %to 4501 %by 500;
        proc whatever data=mydata(firstobs=&amp;amp;start obs=500);
             ...
        run;
        proc iml;
            use mydata(firstobs=&amp;amp;start obs=500);
            read var _num_ /* or a list of variable names */  into x;
            ...
        quit;
    %end;
%mend;

%dothis&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2019 10:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550840#M4640</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-13T10:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a  Do loop when the code is a  mixed between Proc/IML and other SAS/STAT</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550843#M4641</link>
      <description>&lt;P&gt;use SUBMIT in IML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc iml;&lt;/P&gt;
&lt;P&gt;.......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;submit ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;proc reg data=class;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;...........&lt;/P&gt;
&lt;P&gt;endsub;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2019 11:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550843#M4641</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-04-13T11:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a  Do loop when the code is a  mixed between Proc/IML and other SAS/STAT</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550852#M4642</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;My issue is that I need to read and estimate the density for the data using three types of censoring&lt;/P&gt;&lt;P&gt;case 1: censoring from the begging, for this case I&lt;STRONG&gt; will not&lt;/STRONG&gt; take the first 500 observations, I start my data from obs=501 till the end of the data.&lt;/P&gt;&lt;P&gt;case 2:&amp;nbsp; &amp;nbsp;censoring the last 500 observation, so my data will start from obs=1 and end with 10154-500&lt;/P&gt;&lt;P&gt;Case 3: censoring from the middle so I will read all the data except the 500 observations from the middle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each of these data sets I compute the kernel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problems is that I have to do it again for 1000, 1500,...,5000.&lt;/P&gt;&lt;P&gt;I have done it by adjusting the numbers manually and run the code, but this is very primitive and I want something rigorous.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2019 19:28:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550852#M4642</guid>
      <dc:creator>Salah</dc:creator>
      <dc:date>2019-04-13T19:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a  Do loop when the code is a  mixed between Proc/IML and other SAS/STAT</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550853#M4643</link>
      <description>&lt;P&gt;&amp;nbsp;That may work. Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2019 19:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550853#M4643</guid>
      <dc:creator>Salah</dc:creator>
      <dc:date>2019-04-13T19:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a  Do loop when the code is a  mixed between Proc/IML and other SAS/STAT</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550855#M4644</link>
      <description>&lt;P&gt;That's fine. As I said, you can modify the program for other situations such as you describe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;N = 10154;
do case = 1 to 3;
   if case=1 then 
      obsIdx = 501:N;
   else if case=2 then
      obsIdx = 1:(N-500);
   else if case=3 then do;
      middle = round(N/2);
      midIdx = (middle-249):(middle+250); /* or -250 and +249 */
      obsIdx = setdif(1:N, midIdx);
   end;
...
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Apr 2019 20:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-use-a-Do-loop-when-the-code-is-a-mixed-between-Proc-IML/m-p/550855#M4644</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-04-13T20:44:27Z</dc:date>
    </item>
  </channel>
</rss>

