<?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 merge proc means result with a new column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447441#M112401</link>
    <description>&lt;P&gt;Note that the first step is combining the data sets back together. As indicated in previous posts this data structure will make the rest of your work problematic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks, it works. But I have two more questions for the alleq dataset part. For "set eq: indsname=nm;",&amp;nbsp;does it work in case that I have data eq1, eq2, eq3 only? what if I have data&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;eq1, eq2, eq3&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;eq11, eq21, eq31, but I only want the information from&amp;nbsp;eq1, eq2, eq3?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The colon is a prefix short cut, if you have a different naming structure you can use different methods for listing all data sets automatically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PREFIX: will select all data sets that start with PREFIX&lt;/P&gt;
&lt;P&gt;D1-D20 will select all data sets labeled d1 to d20.&lt;/P&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;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;another question for "eqName = scan(nm, 2);" why scan from the second word I think it should be "eqName = scan(nm, 1);". Is it because only one word, so there is no difference between 1 and 2 here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can test this one yourself. Look at the value of NM and you'll see that it includes the library name. This makes sense because you could have data sets with the same name but different libraries such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set work.A perm.A;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Because it has the library name, the data set name is the 2 component in the SCAN() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Mar 2018 15:11:43 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-03-21T15:11:43Z</dc:date>
    <item>
      <title>how to merge proc means result with a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447311#M112337</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to merge the mean and std results only for y and x, created by proc means from dataset eq1, eq2, eq3. And add a new column with dataset name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone show me how to do it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data eq1;
input ID y x z w;
cards;
1 1 1 27 40 
1 2 3 . 29 
1 3 5 30 . 
1 4 7 38 38 
2 1 1 23 45 
2 2 3 32 20 
2 3 5 67 . 
2 4 7 . 27 
3 1 1 33 23 
3 2 3 21 12 
3 3 5 78 . 
3 4 7 13 45 
4 1 1 56 45 
4 2 3 67 13 
4 3 5 . 35 
4 4 7 48 35 
;
run;
data eq2;
input ID y x z w;
cards;
1 1 27 40 8
1 2 . 29 37
1 3 30 . 25
1 4 38 38 23
2 1 23 45 19
2 2 32 20 .
2 3 67 . .
2 4 . 27 .
3 1 33 23 46
3 2 21 12 56
3 3 78 . 34
3 4 13 45 . 
4 1 56 45 23
4 2 67 13 67  
4 3 . 35 13
4 4 48 35 56 
;
run;

data eq3;
input y x ;
cards;
1 1
2 3
3 5
4 7
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Mar 2018 03:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447311#M112337</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-03-21T03:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge proc means result with a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447313#M112339</link>
      <description>What do you like your desired data output to look like?</description>
      <pubDate>Wed, 21 Mar 2018 03:49:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447313#M112339</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2018-03-21T03:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge proc means result with a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447314#M112340</link>
      <description>&lt;P&gt;Use concatenate and merge:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data allEq;
length eqName $32;
set eq: indsname=nm;
eqName = scan(nm, 2);
run;

proc sort data=allEq; by eqName id; run;

proc means data=allEq noprint;
by eqName id;
var x y;
output out=allMeans mean= std= / autoname;
run;

data want;
merge allEq allMeans(drop=_type_ _freq_);
by eqName id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Mar 2018 03:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447314#M112340</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-21T03:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge proc means result with a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447315#M112341</link>
      <description>13columns, 1 column with name of eq1-3, 4 columns for each dataset (2 for mean of y and z, 2 for std of yz)&lt;BR /&gt;3 rows, one row for the results from each dataset.&lt;BR /&gt;I also want to change the name of std to variance.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Mar 2018 04:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447315#M112341</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-03-21T04:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge proc means result with a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447418#M112390</link>
      <description>&lt;P&gt;Thanks, it works. But I have two more questions for the alleq dataset part. For "set eq: indsname=nm;",&amp;nbsp;does it work in case that I have data eq1, eq2, eq3 only? what if I have data&amp;nbsp;&lt;SPAN&gt;eq1, eq2, eq3&lt;/SPAN&gt;,&lt;SPAN&gt;eq11, eq21, eq31, but I only want the information from&amp;nbsp;eq1, eq2, eq3?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;another question for "eqName = scan(nm, 2);" why scan from the second word I think it should be "eqName = scan(nm, 1);". Is it because only one word, so there is no difference between 1 and 2 here?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks again.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 14:08:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447418#M112390</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-03-21T14:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge proc means result with a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447440#M112400</link>
      <description>&lt;P&gt;Note that the first step is combining the data sets back together. As indicated in previous posts this data structure will make the rest of your work problematic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks, it works. But I have two more questions for the alleq dataset part. For "set eq: indsname=nm;",&amp;nbsp;does it work in case that I have data eq1, eq2, eq3 only? what if I have data&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;eq1, eq2, eq3&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;eq11, eq21, eq31, but I only want the information from&amp;nbsp;eq1, eq2, eq3?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The colon is a prefix short cut, if you have a different naming structure you can use different methods for listing all data sets automatically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PREFIX: will select all data sets that start with PREFIX&lt;/P&gt;
&lt;P&gt;D1-D20 will select all data sets labeled d1 to d20.&lt;/P&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;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;another question for "eqName = scan(nm, 2);" why scan from the second word I think it should be "eqName = scan(nm, 1);". Is it because only one word, so there is no difference between 1 and 2 here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can test this one yourself. Look at the value of NM and you'll see that it includes the library name. This makes sense because you could have data sets with the same name but different libraries such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set work.A perm.A;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Because it has the library name, the data set name is the 2 component in the SCAN() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447440#M112400</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-21T15:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge proc means result with a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447441#M112401</link>
      <description>&lt;P&gt;Note that the first step is combining the data sets back together. As indicated in previous posts this data structure will make the rest of your work problematic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks, it works. But I have two more questions for the alleq dataset part. For "set eq: indsname=nm;",&amp;nbsp;does it work in case that I have data eq1, eq2, eq3 only? what if I have data&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;eq1, eq2, eq3&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;eq11, eq21, eq31, but I only want the information from&amp;nbsp;eq1, eq2, eq3?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The colon is a prefix short cut, if you have a different naming structure you can use different methods for listing all data sets automatically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PREFIX: will select all data sets that start with PREFIX&lt;/P&gt;
&lt;P&gt;D1-D20 will select all data sets labeled d1 to d20.&lt;/P&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;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;another question for "eqName = scan(nm, 2);" why scan from the second word I think it should be "eqName = scan(nm, 1);". Is it because only one word, so there is no difference between 1 and 2 here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can test this one yourself. Look at the value of NM and you'll see that it includes the library name. This makes sense because you could have data sets with the same name but different libraries such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set work.A perm.A;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Because it has the library name, the data set name is the 2 component in the SCAN() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447441#M112401</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-21T15:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge proc means result with a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447442#M112402</link>
      <description>&lt;P&gt;Note that the first step is combining the data sets back together. As indicated in previous posts this data structure will make the rest of your work problematic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks, it works. But I have two more questions for the alleq dataset part. For "set eq: indsname=nm;",&amp;nbsp;does it work in case that I have data eq1, eq2, eq3 only? what if I have data&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;eq1, eq2, eq3&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;eq11, eq21, eq31, but I only want the information from&amp;nbsp;eq1, eq2, eq3?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The colon is a prefix short cut, if you have a different naming structure you can use different methods for listing all data sets automatically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PREFIX: will select all data sets that start with PREFIX&lt;/P&gt;
&lt;P&gt;D1-D20 will select all data sets labeled d1 to d20.&lt;/P&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;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;another question for "eqName = scan(nm, 2);" why scan from the second word I think it should be "eqName = scan(nm, 1);". Is it because only one word, so there is no difference between 1 and 2 here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can test this one yourself. Look at the value of NM and you'll see that it includes the library name. This makes sense because you could have data sets with the same name but different libraries such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set work.A perm.A;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Because it has the library name, the data set name is the 2 component in the SCAN() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:11:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447442#M112402</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-21T15:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge proc means result with a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447489#M112429</link>
      <description>&lt;P&gt;Thanks, I am pleased to learn it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-merge-proc-means-result-with-a-new-column/m-p/447489#M112429</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-03-21T16:46:25Z</dc:date>
    </item>
  </channel>
</rss>

