<?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: Output Dataset with Number of Observations Used from Proc Logistic in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956810#M47902</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436751"&gt;@chester2018&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to explain the issue with your DATA step: The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0nw8trwk5ooesn1o8zrtd5c6j1t.htm" target="_blank" rel="noopener"&gt;NMISS function&lt;/A&gt;&amp;nbsp;requires numeric arguments, but some of your variables are character. Use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1tth4ltf640din1ey86ubo2lky2.htm" target="_blank" rel="noopener"&gt;CMISS function&lt;/A&gt; instead. It works for both numeric and character arguments. Since you restricted dataset USED_OBS to the variables of interest, you can also simplify the IF condition:&lt;/P&gt;
&lt;PRE&gt;if cmiss(of &lt;STRONG&gt;_all_&lt;/STRONG&gt;)=0;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Tue, 21 Jan 2025 22:36:18 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2025-01-21T22:36:18Z</dc:date>
    <item>
      <title>Output Dataset with Number of Observations Used from Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956802#M47898</link>
      <description>&lt;P&gt;Hi everyone! I'm running into some trouble with making a dataset from proc logistic. My number of observations used (2913) is smaller than the number of observations read (4457), and I want to create a dataset with only the number of observations used. Below is my code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc logistic data=mydata;
    class education_cat (ref="0") income_cat (ref="0")  work_cat (ref="0");
    model PASB_Cat (ref="0") = education_cat income_cat
	 work_cat / link=glogit;
	output out=used_obs (keep=PASB_Cat education_cat income_cat 
	 work_cat);
run;

data used_obs_clean;
    set used_obs;
    if nmiss(of PASB_Cat education_cat income_cat
	 work_cat) = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Below is the log of the code, which basically says "Invalid Numeric Data"&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
       71:17   72:46   
 NOTE: Invalid numeric data, PASB_Cat='0' , at line 71 column 17.&lt;/PRE&gt;
&lt;P&gt;And of course since I have error messages, my output dataset has no data! I appreciate any help!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 21:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956802#M47898</guid>
      <dc:creator>chester2018</dc:creator>
      <dc:date>2025-01-21T21:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Output Dataset with Number of Observations Used from Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956804#M47899</link>
      <description>&lt;P&gt;Use an ODS OUTPUT statement for this, not the OUTPUT statement. The ODS OUTPUT statement can save any displayed table in a data set. See &lt;A href="http://support.sas.com/kb/22949" target="_self"&gt;this note&lt;/A&gt; on using it. The table you want is named NObs, so use this statement to keep just the number of observations used (dropping the number read):&lt;/P&gt;
&lt;P&gt;ods output nobs=myobsused(where=(label ? "Used"));&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 21:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956804#M47899</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2025-01-21T21:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: Output Dataset with Number of Observations Used from Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956810#M47902</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436751"&gt;@chester2018&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to explain the issue with your DATA step: The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0nw8trwk5ooesn1o8zrtd5c6j1t.htm" target="_blank" rel="noopener"&gt;NMISS function&lt;/A&gt;&amp;nbsp;requires numeric arguments, but some of your variables are character. Use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1tth4ltf640din1ey86ubo2lky2.htm" target="_blank" rel="noopener"&gt;CMISS function&lt;/A&gt; instead. It works for both numeric and character arguments. Since you restricted dataset USED_OBS to the variables of interest, you can also simplify the IF condition:&lt;/P&gt;
&lt;PRE&gt;if cmiss(of &lt;STRONG&gt;_all_&lt;/STRONG&gt;)=0;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 21 Jan 2025 22:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956810#M47902</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-01-21T22:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Output Dataset with Number of Observations Used from Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956812#M47903</link>
      <description>debugged?</description>
      <pubDate>Tue, 21 Jan 2025 22:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956812#M47903</guid>
      <dc:creator>coder1234</dc:creator>
      <dc:date>2025-01-21T22:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Output Dataset with Number of Observations Used from Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956813#M47904</link>
      <description>&lt;P&gt;Thanks for the reply! But I'm struggling with the variables not being in the smaller dataset. This is my new code!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc logistic data=mydata;
    class education_cat (ref="0") income_cat (ref="0")  work_cat (ref="0");
    model PASB_Cat (ref="0") = education_cat income_cat
	 work_cat / link=glogit;
	ods output nobs=myobsused (keep=PASB_Cat education_cat income_cat 
	 work_cat);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Based on the Number of Observations Read (2913), I should have the variables that were read in the smaller dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 23:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956813#M47904</guid>
      <dc:creator>chester2018</dc:creator>
      <dc:date>2025-01-21T23:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Output Dataset with Number of Observations Used from Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956814#M47905</link>
      <description>Your wording is confusing, but I now have to guess that you mean you want a data set of all of the observations that were used in the analysis. What I showed with the ODS OUTPUT statement just provides the actual count of those observations, not the observations themselves. If you want the used observations themselves, then use the OUTPUT statement with the PREDPROBS=I option to create a copy of your data set along with the predicted probabilities of your response levels. In the OUTPUT statement, you can use a WHERE clause to exclude any observations which have a missing predicted probability variable value or a missing response variable value. Such observations did not contribute to fitting the model. For example, if the numeric response is Y with levels 1,2, or 3:&lt;BR /&gt;&lt;BR /&gt;output out=myusedobs(where=(IP_1 ne . and Y ne .)) predprobs=i;</description>
      <pubDate>Tue, 21 Jan 2025 23:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956814#M47905</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2025-01-21T23:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Output Dataset with Number of Observations Used from Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956818#M47907</link>
      <description>As FreelanceReinh said, using CMISS() instead of NMISS().&lt;BR /&gt;CMISS() could take into account of both character and numeric variable, while NMISS() is only suited for numeric variable:&lt;BR /&gt;&lt;BR /&gt;if nmiss(PASB_Cat , education_cat  ,income_cat   ,work_cat) = 0;&lt;BR /&gt;--&amp;gt;&lt;BR /&gt;if cmiss(PASB_Cat , education_cat  ,income_cat   ,work_cat) = 0;</description>
      <pubDate>Wed, 22 Jan 2025 00:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956818#M47907</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-22T00:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Output Dataset with Number of Observations Used from Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956836#M47913</link>
      <description>&lt;P&gt;This worked! Thank you so much for your help! I truly appreciate it! My smaller dataset has all the variables/observations I needed and there are no missing values!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 03:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Output-Dataset-with-Number-of-Observations-Used-from-Proc/m-p/956836#M47913</guid>
      <dc:creator>chester2018</dc:creator>
      <dc:date>2025-01-22T03:40:08Z</dc:date>
    </item>
  </channel>
</rss>

