<?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: Creat missing value randomly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creat-missing-value-randomly/m-p/32671#M6315</link>
    <description>This DATA step will create the randomly missing values.  A simple extension could be used to create n randomly missing values.&lt;BR /&gt;
[pre]data missran;&lt;BR /&gt;
input A B C D E F G;&lt;BR /&gt;
array allvar {7} a--g;&lt;BR /&gt;
* randomly set one var to missing;&lt;BR /&gt;
loc = ceil(ranuni(0)*dim(allvar));&lt;BR /&gt;
allvar{loc} = .;&lt;BR /&gt;
* replace missing with mean of other vars;&lt;BR /&gt;
allvar{loc} = mean(of a--g);&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 3 4 3 2 3 4 &lt;BR /&gt;
2 4 3 4 5 6 2 &lt;BR /&gt;
2 5 3 4 5 3 1&lt;BR /&gt;
1 2 3 3 2 1 3 &lt;BR /&gt;
2 5 4 3 4 1 3 &lt;BR /&gt;
run;&lt;BR /&gt;
proc print data=missran;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Fri, 12 Nov 2010 05:12:47 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2010-11-12T05:12:47Z</dc:date>
    <item>
      <title>Creat missing value randomly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creat-missing-value-randomly/m-p/32670#M6314</link>
      <description>Hi, I'm trying to creat new datasets that contains missing vlaues using exist data.&lt;BR /&gt;
&lt;BR /&gt;
If I have a data that contains 7 continuous variables like below.&lt;BR /&gt;
&lt;BR /&gt;
A B C D E F G&lt;BR /&gt;
1 3 4 3 2 3 4 &lt;BR /&gt;
2 4 3 4 5 6 2 &lt;BR /&gt;
2 5 3 4 5 3 1&lt;BR /&gt;
1 2 3 3 2 1 3 &lt;BR /&gt;
2 5 4 3 4 1 3 &lt;BR /&gt;
&lt;BR /&gt;
I want to make missing randomly, but same number of missing within each person like below.&lt;BR /&gt;
&lt;BR /&gt;
data-1 (1 missing per person)&lt;BR /&gt;
&lt;BR /&gt;
A B C D E F G&lt;BR /&gt;
1 . 4 3 2 3 4 &lt;BR /&gt;
2 4 3 . 5 6 2 &lt;BR /&gt;
2 5 . 4 5 3 1&lt;BR /&gt;
. 2 3 3 2 1 3 &lt;BR /&gt;
2 5 4 3 4 . 3 &lt;BR /&gt;
&lt;BR /&gt;
data-2 (2 missing per person)&lt;BR /&gt;
&lt;BR /&gt;
A B C D E F G&lt;BR /&gt;
1 . 4 3 . 3 4 &lt;BR /&gt;
2 4 . . 5 6 2 &lt;BR /&gt;
2 5 . 4 5 . 1&lt;BR /&gt;
. 2 3 3 . 1 3 &lt;BR /&gt;
2 5 . 3 4 . 3 &lt;BR /&gt;
&lt;BR /&gt;
...up to 6 missings per person.&lt;BR /&gt;
&lt;BR /&gt;
Also, is there any way to replace the missing value with mean of rest of values?&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Thu, 11 Nov 2010 23:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creat-missing-value-randomly/m-p/32670#M6314</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-11T23:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creat missing value randomly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creat-missing-value-randomly/m-p/32671#M6315</link>
      <description>This DATA step will create the randomly missing values.  A simple extension could be used to create n randomly missing values.&lt;BR /&gt;
[pre]data missran;&lt;BR /&gt;
input A B C D E F G;&lt;BR /&gt;
array allvar {7} a--g;&lt;BR /&gt;
* randomly set one var to missing;&lt;BR /&gt;
loc = ceil(ranuni(0)*dim(allvar));&lt;BR /&gt;
allvar{loc} = .;&lt;BR /&gt;
* replace missing with mean of other vars;&lt;BR /&gt;
allvar{loc} = mean(of a--g);&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 3 4 3 2 3 4 &lt;BR /&gt;
2 4 3 4 5 6 2 &lt;BR /&gt;
2 5 3 4 5 3 1&lt;BR /&gt;
1 2 3 3 2 1 3 &lt;BR /&gt;
2 5 4 3 4 1 3 &lt;BR /&gt;
run;&lt;BR /&gt;
proc print data=missran;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 12 Nov 2010 05:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creat-missing-value-randomly/m-p/32671#M6315</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-11-12T05:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creat missing value randomly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creat-missing-value-randomly/m-p/32672#M6316</link>
      <description>Thanks a lot!!</description>
      <pubDate>Sun, 14 Nov 2010 00:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creat-missing-value-randomly/m-p/32672#M6316</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-14T00:51:37Z</dc:date>
    </item>
  </channel>
</rss>

