<?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: Extracting values from PROC MEANS, use them in a new table to compute . in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Extracting-values-from-PROC-MEANS-use-them-in-a-new-table-to/m-p/542054#M74156</link>
    <description>&lt;P&gt;Thanks that's what I was looking.&lt;/P&gt;&lt;P&gt;Works perfectly.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
    <pubDate>Mon, 11 Mar 2019 15:10:57 GMT</pubDate>
    <dc:creator>OscarUvalle</dc:creator>
    <dc:date>2019-03-11T15:10:57Z</dc:date>
    <item>
      <title>Extracting values from PROC MEANS, use them in a new table to compute .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Extracting-values-from-PROC-MEANS-use-them-in-a-new-table-to/m-p/541997#M74153</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, I'm looking for a fancy way to solve my problem. Even though the code is doing what I need I am not happy with it.&lt;/P&gt;&lt;P&gt;What I need is to take values from two OUTPUTs obtained by PROC LOGISTIC and PROC MEANS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I assign&amp;nbsp;the mean value obtained from&amp;nbsp;PROC MEANS to a new variable? In this case, I have two means, one where the class is 1 and the other when the class is 0. Therefore, I need to create a variable called mean_y_1 and&amp;nbsp;&amp;nbsp;mean_y_0. I assigned those values by hand, how can I do using functions?.&amp;nbsp; Check the code below.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ORIGINAL;
	INPUT ID Y CLASS;
   	CARDS;
1 12000 1
2 0 0
3 0.6 0 
4 0.7 1
5 19 0
;
RUN;

PROC LOGISTIC DATA = ORIGINAL PLOT = NONE OUTEST = LOGIT_ESTIMATESS;
	MODEL  CLASS(EVENT = '1')= Y /; RUN;

PROC MEANS DATA = ORIGINAL n MEAN STD MAXDEC = 4;
  CLASS CLASS;  VAR ID; OUTPUT OUT= ORIGINAL_MEANS MEAN= MEAN_Y; RUN;

/* TAKING VALUES FROM LOGIT_ESTIMATES AND ORIGINAL_MEANS. BOTH TABLES ARE THE OUTPUT OF &lt;BR /&gt;PROC LOGISTIC AND PROC MEANS */ 

DATA ORIGINAL_ANALYSIS; DROP _FREQ_ _TYPE_ ; SET LOGIT_ESTIMATESS;
/* ASSIGNING THE MEAN VALUE BY CLASS */
	MEAN_Y_1 = 3.3333;
 	MEAN_Y_0 = 2.5000;

/* WHEN CLASS = 1 */
 STEP1_1 = INTERCEPT + (Y * MEAN_Y_1) ;  
/* WHEN CLASS = 0 */
 STEP1_0 = INTERCEPT + (Y * MEAN_Y_0) ;  

 FORMAT STEP1_1  STEP1_0 COMMA32.31;
 LABEL STEP1_1 = 'AVERAGE METHOD PROBABILITY OF CLASS = 1';
 LABEL STEP1_0 = 'AVERAGE METHOD PROBABILITY OF CLASS = 1';
RUN;
PROC PRINT DATA = ORIGINAL_ANALYSIS LABEL; FORMAT STEP1_1 STEP1_0 COMMA10.4 ;VAR STEP1_1 STEP1_0 ; RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 13:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Extracting-values-from-PROC-MEANS-use-them-in-a-new-table-to/m-p/541997#M74153</guid>
      <dc:creator>OscarUvalle</dc:creator>
      <dc:date>2019-03-11T13:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting values from PROC MEANS, use them in a new table to compute .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Extracting-values-from-PROC-MEANS-use-them-in-a-new-table-to/m-p/542003#M74154</link>
      <description>&lt;P&gt;a fix&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
PROC MEANS DATA = ORIGINAL n MEAN STD MAXDEC = 4 nway;
  CLASS CLASS;  VAR ID; OUTPUT OUT= ORIGINAL_MEANS MEAN= MEAN_Y; RUN;

DATA ORIGINAL_ANALYSIS;  SET LOGIT_ESTIMATESS;
if _n_=1 then do; 
set ORIGINAL_MEANS(firstobs=1 keep=mean_y rename=(mean_y=  MEAN_Y_0));
set ORIGINAL_MEANS(firstobs=2 keep=mean_y rename=(mean_y=  MEAN_Y_1));
end;
/* ASSIGNING THE MEAN VALUE BY CLASS */
/*	MEAN_Y_1 = 3.3333;*/
/* 	MEAN_Y_0 = 2.5000;*/

/* WHEN CLASS = 1 */
 STEP1_1 = INTERCEPT + (Y * MEAN_Y_1) ;  
/* WHEN CLASS = 0 */
 STEP1_0 = INTERCEPT + (Y * MEAN_Y_0) ;  

 FORMAT STEP1_1  STEP1_0 COMMA32.31;
 LABEL STEP1_1 = 'AVERAGE METHOD PROBABILITY OF CLASS = 1';
 LABEL STEP1_0 = 'AVERAGE METHOD PROBABILITY OF CLASS = 1';
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Mar 2019 13:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Extracting-values-from-PROC-MEANS-use-them-in-a-new-table-to/m-p/542003#M74154</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-11T13:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting values from PROC MEANS, use them in a new table to compute .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Extracting-values-from-PROC-MEANS-use-them-in-a-new-table-to/m-p/542054#M74156</link>
      <description>&lt;P&gt;Thanks that's what I was looking.&lt;/P&gt;&lt;P&gt;Works perfectly.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Extracting-values-from-PROC-MEANS-use-them-in-a-new-table-to/m-p/542054#M74156</guid>
      <dc:creator>OscarUvalle</dc:creator>
      <dc:date>2019-03-11T15:10:57Z</dc:date>
    </item>
  </channel>
</rss>

