<?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: Missing values won't be placed in original data file using do loops (Instead of using array) in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/589013#M4835</link>
    <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How/m-p/587605#M4794" target="_blank"&gt;https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How/m-p/587605#M4794&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2019 12:19:42 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-09-16T12:19:42Z</dc:date>
    <item>
      <title>Re: Missing values won't be placed in original data file using do loops (Instead of using array)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588830#M4830</link>
      <description>Thanks. But what do you mean "Post it at IML forum"? I never post a IML question, this is the first time I asked it. Can you tell me what do you mean in terms of solving this problem? Thanks.</description>
      <pubDate>Sun, 15 Sep 2019 13:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588830#M4830</guid>
      <dc:creator>wzy1993</dc:creator>
      <dc:date>2019-09-15T13:49:26Z</dc:date>
    </item>
    <item>
      <title>How</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587605#M4836</link>
      <description />
      <pubDate>Thu, 12 Sep 2019 15:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587605#M4836</guid>
      <dc:creator>k93943</dc:creator>
      <dc:date>2019-09-12T15:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to Replace Missing Values using Proc iml and do loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587611#M4837</link>
      <description>&lt;P&gt;I don't have a matrix to test this on, but I think this ought to work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where = loc(m=-99 or m=99);
m[where]=.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;No loops needed (in general, you don't want to use loops in IML anyway, you want to use matrix commands; the only time you would use loops is if you are developing some sort of iterative algorithm)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2019 18:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587611#M4837</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-10T18:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Replace Missing Values using Proc iml and do loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587698#M4838</link>
      <description>&lt;P&gt;If you receive values that you know are going to be set to missing, such as with an indicator code like this, you might consider reading the data into missing to begin with.&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
invalue myvalues
'99', '-99' = .
;
run;
/* reading raw data*/
data example;
   input v1 :myvalues. ;
datalines;
1 
2
9
99
-99
-45
45
;&lt;/PRE&gt;
&lt;P&gt;Another option would be use an assignment of special missing in the format like .Z (replace the . in the invalue with .Z )that would allow you to tell the difference between missing because no value was read or the missing set due to this rule. The value is still missing for purposes of calculations but can be printed or examined.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 15:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587698#M4838</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-11T15:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Replace Missing Values using Proc iml and do loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587803#M4839</link>
      <description>&lt;P&gt;Why not post it at IML forum ? since it is IML question ?&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; is there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
   input v1 ;
   v2=v1;
datalines;
1 
2
9
99
-99
-45
45
;

proc iml;
use example;
read all var _all_ into x[c=vname];
close;

x[loc(x=99 | x=-99)]=.;

create want from x[c=vname];
append from x;
close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Sep 2019 12:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587803#M4839</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-11T12:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to Replace Missing Values using Proc iml and do loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587811#M4840</link>
      <description>&lt;P&gt;As Paige and KSharp said, use the LOC function. However, &lt;A href="https://blogs.sas.com/content/iml/2012/11/19/beware-the-naked-loc.html" target="_self"&gt;never use a "naked LOC": &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;always check that at least one observation satisfied the search criterion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;missingIdx = loc(m=-99 | m=99);
if ncol(missingIdx)&amp;gt;0 then
    m[where] = .;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 12:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/587811#M4840</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-09-11T12:38:52Z</dc:date>
    </item>
    <item>
      <title>Missing values won't be placed in original data file using do loops (Instead of using array)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588789#M4831</link>
      <description>&lt;DIV&gt;Here is the code that I used trying to replace 99 and -99 with period "." using "do" loops (we are not allowed to use array in this exercise). However, the code I did only generates the replacing results in the result window, but 99 and -99 won't be replaced in the original data in the library I created. I have tried many times, but I don't why know the period won't replace 99 and -99 in the original data. I attached my code file here well. Please let me know if anyone can answer my questions.&amp;nbsp; I attended my code as "hw2" and the data file as "exercise2" below.&amp;nbsp; &amp;nbsp; Thanks!!!!&lt;/DIV&gt;&lt;DIV&gt;My code for the 1st and 2nd question (Only the code for 2nd question has issues):&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;libname HW2 'C:\Users\Administrator\Desktop\BU_2019\BS 803\HW\HW2';&lt;BR /&gt;/*1.Read only the following variables into a matrix called CG: NACZZMS, NACCLMI, NACCZLMD,&lt;/DIV&gt;&lt;DIV&gt;NACCDFT, NACCAGEB.*/&lt;BR /&gt;proc iml;&lt;BR /&gt;/* read variables from a SAS data set into a matrix */&lt;BR /&gt;&amp;nbsp; varNames = {"NACCZMMS" "NACCZLMI" "NACCZLMD" "NACCZDFT" "NACCAGEB"};&lt;BR /&gt;use hw2.exercise2; /* open data for reading &amp;nbsp; &amp;nbsp; */&lt;BR /&gt;read all var varNames into CG; &amp;nbsp;/* create matrix with 5 cols */&lt;BR /&gt;close hw2.exercise2;&lt;BR /&gt;print CG[c=varNames]; &amp;nbsp;&lt;BR /&gt;proc iml;&lt;BR /&gt;/* read variables from a SAS data set into a matrix */&lt;BR /&gt;&amp;nbsp; varNames = {"NACCZMMS" "NACCZLMI" "NACCZLMD" "NACCZDFT"};&lt;BR /&gt;use hw2.exercise2; /* open data for reading &amp;nbsp; &amp;nbsp; */&lt;BR /&gt;read all var varNames into CG; &amp;nbsp;/* create matrix with 5 cols */&lt;BR /&gt;do j=1 to 4;&lt;BR /&gt;&amp;nbsp; do i=1 to nrow(CG);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if CG[i,j]=-99 | CG[i,j]=99 then CG[i,j]=.;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;end;&lt;BR /&gt;print CG[c=varNames];&lt;BR /&gt;quit;&lt;/DIV&gt;</description>
      <pubDate>Sun, 15 Sep 2019 02:15:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588789#M4831</guid>
      <dc:creator>wzy1993</dc:creator>
      <dc:date>2019-09-15T02:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Missing values won't be placed in original data file using do loops (Instead of using array)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588810#M4832</link>
      <description>&lt;P&gt;I don't know enough about Proc IML to tell if it allows you to replace a source table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've nicely commented your code and it doesn't say anywhere "write" or "update" - which is what's missing.&lt;/P&gt;
&lt;P&gt;Here a link how such a write could look like:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2011/04/18/writing-data-from-a-matrix-to-a-sas-data-set.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2011/04/18/writing-data-from-a-matrix-to-a-sas-data-set.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here docu sample code how to update data:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/imlug/67502/HTML/default/viewer.htm#imlug_worksasdatasets_sect015.htm" target="_blank" rel="noopener"&gt;http://support.sas.com/documentation/cdl/en/imlug/67502/HTML/default/viewer.htm#imlug_worksasdatasets_sect015.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2019 08:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588810#M4832</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-09-15T08:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Missing values won't be placed in original data file using do loops (Instead of using array)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588822#M4833</link>
      <description>&lt;P&gt;Post it at IML forum. I remembered there is already a post like yours in IML forum.&lt;/P&gt;
&lt;P&gt;Aren't you&amp;nbsp; the same person ?&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2019 11:20:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588822#M4833</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-15T11:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Missing values won't be placed in original data file using do loops (Instead of using array)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588829#M4834</link>
      <description>Thanks. The "print CG[c=varNames];" before "quit" gives me the replaced results, but only in SAS Result window. However, the original data in the library I created still is the same, which means missing values 99 and -99 still exist. That is the issue.</description>
      <pubDate>Sun, 15 Sep 2019 13:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/588829#M4834</guid>
      <dc:creator>wzy1993</dc:creator>
      <dc:date>2019-09-15T13:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: Missing values won't be placed in original data file using do loops (Instead of using array)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/589013#M4835</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How/m-p/587605#M4794" target="_blank"&gt;https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How/m-p/587605#M4794&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 12:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/589013#M4835</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-16T12:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Missing values won't be placed in original data file using do loops (Instead of using array)</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/589024#M4841</link>
      <description>&lt;P&gt;I have merged the two separate threads into one thread.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 12:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Re-Missing-values-won-t-be-placed-in-original-data-file-using-do/m-p/589024#M4841</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-09-16T12:46:23Z</dc:date>
    </item>
  </channel>
</rss>

