<?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: How to tag along one more variable to ouput in proc means? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-tag-along-one-more-variable-to-ouput-in-proc-means/m-p/724813#M225064</link>
    <description>&lt;P&gt;You need to merge it in in a separate step. As mentioned in your other thread, SAS procedures won't do anything that is not in their predefined capabilities.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Mar 2021 10:50:20 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-03-09T10:50:20Z</dc:date>
    <item>
      <title>How to tag along one more variable to ouput in proc means?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tag-along-one-more-variable-to-ouput-in-proc-means/m-p/724808#M225060</link>
      <description>&lt;P&gt;Hi all SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally, &lt;STRONG&gt;Output out&lt;/STRONG&gt; statement in &lt;STRONG&gt;PROC MEANS&lt;/STRONG&gt; only show us the variables called by "&lt;STRONG&gt;BY&lt;/STRONG&gt;" statement, and mean, sum,..... called by statement&lt;STRONG&gt; Output out&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please tell me how can I tag along another variable call "&lt;STRONG&gt;LOC&lt;/STRONG&gt;" to the output here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I have a original dataset called &lt;STRONG&gt;chl_d&lt;/STRONG&gt;. The frequency is daily, &lt;STRONG&gt;LOC&lt;/STRONG&gt; is 3 characters indexed for a country.&lt;/P&gt;
&lt;P&gt;A part is like that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;GVKEY	IID	DATADATE	CIK	        CONML	                    LOC     SIC	    ISIN	        SEDOL	EXCHG	AJEXDI	CSHOC	        CSHTRD	    CURCDD	PRCCD	PRCHD	PRCLD	PRCSTD	TPCI	TRFD	ex_rate	gviidkey	prccd_abs	prccd_abs_	    lagprccd_abs_	lagajexdi	lagtrfd	raw_return	  log_raw_return	i	raw_return_abs	dollar_vol	    prccd_	        prchd_	        prcld_	       appday	eta	            c	            eta_lead1	  year	S_2DC
001166	01W	04JAN1999	0000351483	ASM     International NV	NLD  	3559	NL0000334118	5165294	104	    1.0000	33724343.0000	45145.0000	EUR	    4.5000	4.6000	4.4500	10	    0	    1	    0.84753	001166_01W	4.5   	    5.3095465647	.	            .	         .	    .	          .	                85	.	            239699.47966	5.3095465647	5.4275364884	5.2505516029	1	    1.674909242	    1.6695064389	1.673635762	  1999	0.0094466755
001166	01W	05JAN1999	0000351483	ASM     International NV	NLD	    3559	NL0000334118	5165294	104	    1.0000	33724343.0000	32047.0000	EUR	    4.5000	4.6000	4.4500	10	    0	    1	    0.84861	001166_01W	4.5     	5.3027892672	5.3095465647	1	         1	    -0.127266942  .	                85	0.1272669424	169938.48764	5.3027892672	5.4206290286	5.2438693864	1	    1.673635762	    1.6682329589	1.7264615191  1999	0.0354737899
001166	01W	06JAN1999	0000351483	ASM     International NV	NLD	    3559	NL0000334118	5165294	104	    1.0000	33724343.0000	550752.0000	EUR	    4.7000	5.0000	4.6000	10	    0	    1	    0.85324	001166_01W	4.7	        5.5084149829	5.3027892672	1	         1	    3.8776897473  1.3552395503	    85	3.8776897473	3033770.5687	5.5084149829	5.8600159392	5.3912146641	1	    1.7264615191	1.7062769199	1.7121731718  1999	0.02181866
001166	01W	07JAN1999	0000351483	ASM     International NV	NLD  	3559	NL0000334118	5165294	104	    1.0000	33724343.0000	323750.0000	EUR	    4.8500	4.9000	4.6000	10	    0	    1	    0.85682	001166_01W	4.85	    5.660465442	    5.5084149829	1	         1	    2.7603305046  1.0153504206	    85	2.7603305046	1832575.6868	5.660465442	    5.7188207558	5.3686888728	1	    1.7121731718	1.7335061224	1.815432897	  1999	0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I use the code below to get the yearly results, however, the results &lt;STRONG&gt;chl_2d_year&lt;/STRONG&gt; just contain some variables, I do not know how to output the variable &lt;STRONG&gt;LOC&lt;/STRONG&gt; in&amp;nbsp;&lt;STRONG&gt;chl_2d_year&lt;/STRONG&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Calculating CHL for each firm per year*/
proc means data=work.chl_d noprint;
	by gviidkey year;
	var S_2DC appday;
	Output out=chl_2d_year (keep=gviidkey year CHL_2d_c appdaysum where=(appdaysum &amp;gt;=12))
	mean=CHL_2d_c sum=SC APPDAYSUM;
	/*Explain: mean of all S_2DC of one company in a year is called CHL
	sum SC APPDAYSUM means SC is sum of S_2DC and APPDAYSUM is sum of APPDAY*/
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The result is like that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;gviidkey	year	CHL_2d_c	    APPDAYSUM
001166_01W	1999	0.0141318615	253
001166_01W	2000	0.0175846612	249
001166_01W	2001	0.0167945019	252
001166_02W	1999	0.0172477814	105
001166_02W	2000	0.0311273775	143
001166_02W	2001	0.0291985294	84
001855_03W	1999	0.0434634019	86
001855_03W	2000	0.0578536264	42
001855_03W	2001	0.1417332222	24
001932_01W	1999	0.0125657319	252&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I want is to insert the column &lt;STRONG&gt;LOC&lt;/STRONG&gt; from&amp;nbsp;&lt;STRONG&gt;chl_d&lt;/STRONG&gt; to&amp;nbsp;&lt;STRONG&gt;chl_2d_year&lt;/STRONG&gt;. Could you please hint me how to do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 10:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tag-along-one-more-variable-to-ouput-in-proc-means/m-p/724808#M225060</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-09T10:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to tag along one more variable to ouput in proc means?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tag-along-one-more-variable-to-ouput-in-proc-means/m-p/724813#M225064</link>
      <description>&lt;P&gt;You need to merge it in in a separate step. As mentioned in your other thread, SAS procedures won't do anything that is not in their predefined capabilities.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 10:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tag-along-one-more-variable-to-ouput-in-proc-means/m-p/724813#M225064</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-09T10:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to tag along one more variable to ouput in proc means?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tag-along-one-more-variable-to-ouput-in-proc-means/m-p/724822#M225066</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212695"&gt;@Phil_NZ&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you can use the ID statement (I would like to include a link to the documentation, but the website seems to be down):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id LOC;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, you also need to add &lt;FONT face="courier new,courier"&gt;LOC&lt;/FONT&gt; to the KEEP= dataset option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Here's an excerpt from the offline help (note that "maximum" refers to alphabetical order in case of character variables such as LOC):&lt;/P&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV class="xis-procStatement"&gt;
&lt;DIV class="xis-procStatementSyntax"&gt;
&lt;H2 id="n05iclegm6n099n1kuoeun9lku5g" class="xis-title"&gt;Syntax&lt;/H2&gt;
&lt;DIV class="xis-syntaxSimple"&gt;
&lt;DIV class="xis-syntaxLevel"&gt;&lt;SPAN class="xis-keyword"&gt;ID&lt;/SPAN&gt; &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: variable(s)" href="http://127.0.0.1:49688/help/proc.hlp/n1niocuk07q2wnn16mz96fboupgc.htm#p04crg6eisoxion1nhfito9ds4yn" target="_blank"&gt;variable(s)&lt;/A&gt;&lt;/SPAN&gt;;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-requiredArgGroup"&gt;
&lt;H3 id="p1mlelufaye3bhn1x68ueid40uzz" class="xis-title"&gt;Required Argument&lt;/H3&gt;
&lt;DIV id="p04crg6eisoxion1nhfito9ds4yn" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;variable(s)&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;identifies one or more variables from the input data set whose maximum values for groups of observations PROC MEANS includes in the output data set.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Mar 2021 11:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tag-along-one-more-variable-to-ouput-in-proc-means/m-p/724822#M225066</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-03-09T11:07:16Z</dc:date>
    </item>
  </channel>
</rss>

