<?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: Creating data with missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271728#M310749</link>
    <description>I need to suppress every imtis=imtis, or every i=1,2,3. The firstobs doesn't remove those lines from the file, it just print less than there is.</description>
    <pubDate>Thu, 19 May 2016 14:43:05 GMT</pubDate>
    <dc:creator>ascasfaegADGSgs</dc:creator>
    <dc:date>2016-05-19T14:43:05Z</dc:date>
    <item>
      <title>Creating data with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271688#M310745</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is my output data file:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3234i34CD431907A60439/image-size/medium?v=v2&amp;amp;px=-1" border="0" alt="Screen Shot 2016-05-19 at 14.43.54.png" title="Screen Shot 2016-05-19 at 14.43.54.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I make those marked (in the picture) values = missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;PRE&gt;%let skirstinys = rannor; /* distribution */
%let imciu_sk = 2; /* data count */
%let imties_dydis = 10; /* data size */
%let LAG = 4;
%let cmax = 0.9;
%let cmin = 0.1;
%let cvalue = (&amp;amp;cmax.-&amp;amp;cmin.)/(&amp;amp;LAG.-1);

data duomenys;
	/* const array */
	array c{&amp;amp;LAG.};
	do q = 1 to dim(c);
		c(q)=&amp;amp;cmax.-(&amp;amp;cvalue.*(q-1));		
	end;
	
	/* X1,X2.. array*/
	array X{&amp;amp;LAG.};
	do n = 1 to dim(X);
		X(n) = &amp;amp;skirstinys.(1);
	end;
	
	/* data */	
	do imtis = 1 to &amp;amp;imciu_sk.;	
		do i = 1 to &amp;amp;imties_dydis.;
			e1=&amp;amp;skirstinys.(1);
			XX=e1;
			do j=1 to dim(c);
				XX=XX+c(j)*X(j);
			end;
			output;
			do f = (&amp;amp;LAG.-1) to 1 by -1;
				X(f+1)=X(f);	
			end;	
			X1=e1;
		end;
	end;
proc print;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm making a research about o&lt;SPAN&gt;bservations dependence of nonstationary process using nonparametric statistics. I need to generate time series with various LAG selections.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;XX is generated using MA(q) process.&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2016 12:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271688#M310745</guid>
      <dc:creator>ascasfaegADGSgs</dc:creator>
      <dc:date>2016-05-19T12:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating data with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271696#M310746</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67354"&gt;@ascasfaegADGSgs﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could add the following line after the assignment statement "&lt;FONT face="courier new,courier"&gt;X(n) = &lt;/FONT&gt;..." in the loop "&lt;FONT face="courier new,courier"&gt;do n = 1&lt;/FONT&gt; ...":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if _n_&amp;lt;n then X(n)=.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please note that this would&amp;nbsp;cause missing values of variable XX in&amp;nbsp;the first three observations as well (and, as a consequence, undesirable notes "Missing values were generated ..." in the log). So, you may want to modify the definition of XX correspondingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: The conditional assignment proposed above can be simplified to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if n&amp;gt;1 then X(n)=.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Reason: The data step iterates only once, hence _n_=1. The assignment statements &lt;SPAN&gt;in the loop "&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;do n = 1&lt;/FONT&gt;&lt;SPAN&gt; ..." affect only the first observation of the output dataset directly, whereas the values of X1-X4 in the subsequent observations are set in the loop&amp;nbsp;"&lt;FONT face="courier new,courier"&gt;do i&amp;nbsp;= 1&lt;/FONT&gt;&lt;SPAN&gt; ...".&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2016 16:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271696#M310746</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-19T16:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating data with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271710#M310747</link>
      <description>&lt;P&gt;How could I delete those first 3 lines in every i=1,2,3 and have fresh data set&amp;nbsp;without them?&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2016 14:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271710#M310747</guid>
      <dc:creator>ascasfaegADGSgs</dc:creator>
      <dc:date>2016-05-19T14:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating data with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271727#M310748</link>
      <description>&lt;P&gt;If you want to suppress the output of the first three lines (observations), you can replace the OUTPUT statement by the following three lines of code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   ctr+1;
   if ctr&amp;gt;3 then output;
   drop ctr;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This creates a counter variable CTR, which is incremented by 1 every time the OUTPUT statement would execute in your original code. The IF condition prevents the execution of the OUTPUT statement for the first three times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to create a new ("fresh") dataset without the first three observations of DUOMENYS, you can use the FIRSTOBS= dataset option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data duomenys2;
set duomenys(firstobs=4);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 May 2016 14:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271727#M310748</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-19T14:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating data with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271728#M310749</link>
      <description>I need to suppress every imtis=imtis, or every i=1,2,3. The firstobs doesn't remove those lines from the file, it just print less than there is.</description>
      <pubDate>Thu, 19 May 2016 14:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271728#M310749</guid>
      <dc:creator>ascasfaegADGSgs</dc:creator>
      <dc:date>2016-05-19T14:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating data with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271734#M310750</link>
      <description>&lt;P&gt;So, you want to delete all observations which had i=1, 2 or 3 in your original DUOMENYS dataset? Then you don't need an additional counter CTR, because you can simply use variable i itself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if i&amp;gt;3 then output;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This would suppress the first three observations for every value of IMTIS (if that's what you meant by "every imtis=imtis").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The new dataset DUOMENYS&lt;STRONG&gt;2&lt;/STRONG&gt; I created using the FIRSTOBS=4 dataset option has 20-3=17 observations. That is, the former first three observations are really gone (not from DUOMENYS, of course). They are &lt;EM&gt;not&lt;/EM&gt; just "not printed."&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2016 14:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-data-with-missing-values/m-p/271734#M310750</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-19T14:57:54Z</dc:date>
    </item>
  </channel>
</rss>

