<?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 a new datset with missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496670#M131401</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input Subject    Base1 Base2 CHG1 CHG2   VisitID;
cards;
1                4           5           . .                      1
1                4           5         2            3         2
2                4           5         . .                         1
3                4           5           .  .                       1
;


proc sql;
create table want as
select *
from have
group by subject
having max((n(CHG1 ,CHG2)&amp;gt;0))=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139341"&gt;@kmardinian&lt;/a&gt;&amp;nbsp;I think the above will work&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Sep 2018 18:35:09 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-09-18T18:35:09Z</dc:date>
    <item>
      <title>Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496660#M131396</link>
      <description>&lt;P&gt;Hi, I am working with a dataset that looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subject&amp;nbsp;&amp;nbsp;&amp;nbsp; Base1 Base2 CHG1 CHG2&amp;nbsp;&amp;nbsp; VisitID&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to create a new dataset from this data where I can isolate the CHG variables without losing Subject 1 VisitID 1 observation, so that it would look like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subject&amp;nbsp;&amp;nbsp;&amp;nbsp; Base1 Base2 CHG1 CHG2&amp;nbsp;&amp;nbsp; VisitID&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496660#M131396</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-09-18T18:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496668#M131400</link>
      <description>&lt;P&gt;What is it your trying to do here?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496668#M131400</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-09-18T18:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496670#M131401</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input Subject    Base1 Base2 CHG1 CHG2   VisitID;
cards;
1                4           5           . .                      1
1                4           5         2            3         2
2                4           5         . .                         1
3                4           5           .  .                       1
;


proc sql;
create table want as
select *
from have
group by subject
having max((n(CHG1 ,CHG2)&amp;gt;0))=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139341"&gt;@kmardinian&lt;/a&gt;&amp;nbsp;I think the above will work&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496670#M131401</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-18T18:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496672#M131403</link>
      <description>&lt;P&gt;I would like to create a dataset with all the subjects that have observations for the CHG variables without losing my VisitID=1 observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been running this code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data final;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set t4;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if CHG1 ne .;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which obviously doesn't work because then I am losing some of the observations for those subjects, but I'm not sure how else to do it&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496672#M131403</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-09-18T18:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496676#M131405</link>
      <description>&lt;P&gt;Thank you! Do&amp;nbsp; you mind explaining what this statement is doing?&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;CHG1 &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;CHG2&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496676#M131405</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-09-18T18:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496679#M131407</link>
      <description>&lt;P&gt;n function returns the number of non missing values, that's a check and the boolean value is returned is 0 or 1 basing on true of false. And then we filter using having clause to output only true (1) records&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496679#M131407</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-18T18:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496684#M131411</link>
      <description>&lt;P&gt;I am trying to do it with one CHG variable at a time, but for some reason it is giving me this error &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;536&lt;BR /&gt;537&amp;nbsp; proc sql;&lt;BR /&gt;538&amp;nbsp; create table final_all as select * from t4&lt;BR /&gt;539&amp;nbsp; group by subnum having max((n(chg1)&amp;gt;0))=1;&lt;BR /&gt;ERROR: Summary functions nested in this way are not supported.&lt;BR /&gt;540&amp;nbsp; quit;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496684#M131411</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-09-18T18:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496685#M131412</link>
      <description>&lt;P&gt;Still not at all clear what you want. Your words say you just want to include records that have visitid=1 or non-missing CHGx values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    if CHG1 ne . or CHG2 ne . or visitid=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But that is not the output that you posted.&lt;/P&gt;
&lt;P&gt;To get that you would change the last condition to be just the VISITID=1 to for Subject 1&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   if CHG1 ne . or CHG2 ne . or (subject=1 and visitid=1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note you didn't specify if VISITID or SUBJECT are numbers or character strings.&amp;nbsp; I have coded as if they are numbers, but in most instances such identifiers would be character strings since you never need to run statistics on them.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496685#M131412</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-18T18:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496686#M131413</link>
      <description>&lt;P&gt;Not sure what's your requirement , now you seem to change from your initial. Can you clarify your &lt;U&gt;have&lt;/U&gt; and &lt;U&gt;want&amp;nbsp;&lt;/U&gt; plz and make it comprehensive for the community&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496686#M131413</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-18T18:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496690#M131415</link>
      <description>&lt;P&gt;Sorry, it's difficult to properly explain what I was looking for, but Tom's line of code below is exactly what I needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for all your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;   &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; CHG1 &lt;SPAN class="token operator"&gt;ne&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; or CHG2 &lt;SPAN class="token operator"&gt;ne&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; or &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;subject&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; and visitid&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496690#M131415</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-09-18T18:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496692#M131416</link>
      <description>&lt;P&gt;Maybe a subquery might help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select * from have
where subject in (select subject from have where chg1 is not null and chg2 is not null);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496692#M131416</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-09-18T18:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496696#M131417</link>
      <description>&lt;P&gt;Thank you, I will try it this way as well!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496696#M131417</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-09-18T18:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496754#M131461</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139341"&gt;@kmardinian&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to do it with one CHG variable at a time, but for some reason it is giving me this error &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;536&lt;BR /&gt;537&amp;nbsp; proc sql;&lt;BR /&gt;538&amp;nbsp; create table final_all as select * from t4&lt;BR /&gt;539&amp;nbsp; group by subnum having max((n(chg1)&amp;gt;0))=1;&lt;BR /&gt;ERROR: Summary functions nested in this way are not supported.&lt;BR /&gt;540&amp;nbsp; quit;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The reason is: The N function is both a SAS function (to be applied to values within an &lt;EM&gt;observation&lt;/EM&gt;) and an SQL summary function (to be applied to values within a &lt;EM&gt;column&lt;/EM&gt;). As long as there were two arguments it was clear that you meant the &lt;EM&gt;SAS&lt;/EM&gt; function. Now with only one argument it could be the &lt;EM&gt;SQL&lt;/EM&gt; function as well and indeed this is the preferred interpretation by the compiler. Therefore, n(chg1) is already the number of non-missing CHG1 values in the group and the additional SQL summary function MAX is unnecessary and even inappropriate (hence the error).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;So, one of several possible corrections is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;having n(chg1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(Similarly, the original HAVING clause could have been written as &lt;FONT face="courier new,courier"&gt;having n(CHG1) | n(CHG2)&lt;/FONT&gt;.)&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 21:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496754#M131461</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-09-18T21:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new datset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496980#M131573</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input Subject    Base1 Base2 CHG1 CHG2   VisitID;
cards;
1                4           5           . .                      1
1                4           5         2            3         2
2                4           5         . .                         1
3                4           5           .  .                       1
;

proc sort data=have out=want nodupkey;
by  Base1 Base2 CHG1 CHG2   VisitID;
run;
proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Sep 2018 14:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-datset-with-missing-values/m-p/496980#M131573</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-09-19T14:22:54Z</dc:date>
    </item>
  </channel>
</rss>

