<?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: proc print in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51648#M10873</link>
    <description>Thanks a lot for your feedback. &lt;BR /&gt;
&lt;BR /&gt;
I've two data sets&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
DS1&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
Var1     var2      var3      var4&lt;BR /&gt;
&lt;BR /&gt;
X          123       2345     324&lt;BR /&gt;
&lt;BR /&gt;
Y          234       3245     234&lt;BR /&gt;
&lt;BR /&gt;
Z          345       3456     314&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
DS2&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
Var1     var5      &lt;BR /&gt;
&lt;BR /&gt;
X          .98&lt;BR /&gt;
&lt;BR /&gt;
X          .87&lt;BR /&gt;
&lt;BR /&gt;
X          .86&lt;BR /&gt;
&lt;BR /&gt;
Y         .64&lt;BR /&gt;
&lt;BR /&gt;
Y         .65&lt;BR /&gt;
&lt;BR /&gt;
Y         .64&lt;BR /&gt;
&lt;BR /&gt;
Z          .09&lt;BR /&gt;
&lt;BR /&gt;
Z          .34&lt;BR /&gt;
&lt;BR /&gt;
Z          .87&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
I had merged these two files to get the resultant output with var6 var7 var8 (including 1 -5 ), that had to calculate Var1, 2, 3 with 5. During this operation I came across such a situation that repeated the o/p values. &lt;BR /&gt;
&lt;BR /&gt;
for this report it does not include var5 so I could suppress it with no repeated obs.&lt;BR /&gt;
 &lt;BR /&gt;
I need to create a report that includes var5 with all the values but also summarize the other vars with single obs.&lt;BR /&gt;
&lt;BR /&gt;
I would appreceate if you can come up with a solution to this.</description>
    <pubDate>Fri, 03 Oct 2008 16:44:28 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-10-03T16:44:28Z</dc:date>
    <item>
      <title>proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51644#M10869</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
  1       XYZ    658       255.20    107620.11     9169.86     76384.72&lt;BR /&gt;
&lt;BR /&gt;
  2       XYZ     658       255.20    107620.11     9169.86     76384.72&lt;BR /&gt;
&lt;BR /&gt;
  3       XYZ     658       255.20    107620.11     9169.86     76384.72&lt;BR /&gt;
&lt;BR /&gt;
  4       XYZ      658       255.20    107620.11     9169.86     76384.72&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
When I run a code I get my result in the above fashion. As you see, the observations are same and its redundancy to have the rows repeating. I would rather like to see the report as follows.&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
1        XYZ        658       255.20    107620.11     9169.86     76384.72&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
Please tell me how I can squeeze it using proc print or any other proc&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
Thanks,</description>
      <pubDate>Fri, 03 Oct 2008 14:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51644#M10869</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-03T14:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51645#M10870</link>
      <description>proc sort noduprecs&lt;BR /&gt;
(if you first column is observation number and not a data column)&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Fri, 03 Oct 2008 14:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51645#M10870</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-10-03T14:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51646#M10871</link>
      <description>Hi:&lt;BR /&gt;
  It looks like you have duplicate observations in your data. If this is an acceptable condition, then you have several choices:&lt;BR /&gt;
1) Use PROC SORT to create a temporary data set that does not hold any of the duplicate observations and then use PROC PRINT for your REPORT;&lt;BR /&gt;
2) Use PROC REPORT, but define ALL the variables as GROUP variables so that all the duplicate rows collapse into 1 row (where every column is exactly the same)&lt;BR /&gt;
3) Use PROC REPORT, but add up all the numeric variables (assumes that the duplicate observations are valid.&lt;BR /&gt;
 &lt;BR /&gt;
  For example, given this data with the variables NAME, VAR1 and VAR2:&lt;BR /&gt;
[pre]&lt;BR /&gt;
alan 1 1&lt;BR /&gt;
alan 1 1&lt;BR /&gt;
alan 1 1&lt;BR /&gt;
bob 2 2&lt;BR /&gt;
bob 2 2&lt;BR /&gt;
bob 2 2&lt;BR /&gt;
carl 3 3&lt;BR /&gt;
carl 3 3&lt;BR /&gt;
carl 3 3&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
I can produce these results:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Proc PRINT with Dups removed by Proc SORT&lt;BR /&gt;
               &lt;BR /&gt;
Obs    name    var1    var2&lt;BR /&gt;
            &lt;BR /&gt;
 1     alan      1       1&lt;BR /&gt;
 2     bob       2       2&lt;BR /&gt;
 3     carl      3       3&lt;BR /&gt;
    &lt;BR /&gt;
******************************************************&lt;BR /&gt;
Proc REPORT with all variables as GROUP&lt;BR /&gt;
                                &lt;BR /&gt;
                                     Number&lt;BR /&gt;
  name           var1       var2     of Obs&lt;BR /&gt;
  alan              1          1          3&lt;BR /&gt;
  bob               2          2          3&lt;BR /&gt;
  carl              3          3          3&lt;BR /&gt;
                       &lt;BR /&gt;
******************************************************&lt;BR /&gt;
Proc REPORT with Sum of Numeric variables&lt;BR /&gt;
                             &lt;BR /&gt;
                                     Number&lt;BR /&gt;
  name           var1       var2     of Obs&lt;BR /&gt;
  alan              3          3          3&lt;BR /&gt;
  bob               6          6          3&lt;BR /&gt;
  carl              9          9          3&lt;BR /&gt;
          &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
  It really depends on what the significance of the duplicate observations are and how you want them to be treated. (There's probably a PROC SQL SELECT DISTINCT solution for removing dups....but this should be enough to get you started).&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
*** the code;&lt;BR /&gt;
&lt;BR /&gt;
data mydata;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input name $ var1 var2;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
alan 1 1&lt;BR /&gt;
alan 1 1&lt;BR /&gt;
alan 1 1&lt;BR /&gt;
bob 2 2&lt;BR /&gt;
bob 2 2&lt;BR /&gt;
bob 2 2&lt;BR /&gt;
carl 3 3&lt;BR /&gt;
carl 3 3&lt;BR /&gt;
carl 3 3&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                                               &lt;BR /&gt;
proc sort  data=mydata nodupkey out=data2;&lt;BR /&gt;
  by name var1 var2;&lt;BR /&gt;
run;&lt;BR /&gt;
                  &lt;BR /&gt;
ods listing close;&lt;BR /&gt;
options center nodate nonumber;&lt;BR /&gt;
ods html file='c:\temp\nodups.html' style=sasweb;&lt;BR /&gt;
**1) remove dups with PROC SORT and then PRINT;&lt;BR /&gt;
proc print data=data2;&lt;BR /&gt;
  title 'Proc PRINT with Dups removed by Proc SORT';&lt;BR /&gt;
run;&lt;BR /&gt;
                           &lt;BR /&gt;
**2) Use PROC REPORT and define all vars as GROUP; &lt;BR /&gt;
proc report data=mydata nowd;&lt;BR /&gt;
  title 'Proc REPORT with all variables as GROUP';&lt;BR /&gt;
  column name var1 var2 n;&lt;BR /&gt;
  define name /group;&lt;BR /&gt;
  define var1 / group;&lt;BR /&gt;
  define var2 / group;&lt;BR /&gt;
  define n / 'Number of Obs';&lt;BR /&gt;
run;&lt;BR /&gt;
                                         &lt;BR /&gt;
**3) Use PROC REPORT and define some vars as GROUP, SUM the others;&lt;BR /&gt;
proc report data=mydata nowd;&lt;BR /&gt;
  title 'Proc REPORT with Sum of Numeric variables';&lt;BR /&gt;
  column name var1 var2 n;&lt;BR /&gt;
  define name /group;&lt;BR /&gt;
  define var1 / sum;&lt;BR /&gt;
  define var2 / sum;&lt;BR /&gt;
  define n / 'Number of Obs';&lt;BR /&gt;
run;&lt;BR /&gt;
ods _all_ close;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 03 Oct 2008 14:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51646#M10871</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-10-03T14:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51647#M10872</link>
      <description>You can use proc sql:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table /*name of the table*/ as&lt;BR /&gt;
select distinct *&lt;BR /&gt;
from /*name your data came from*/ ;&lt;BR /&gt;
quit;</description>
      <pubDate>Fri, 03 Oct 2008 15:40:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51647#M10872</guid>
      <dc:creator>yonib</dc:creator>
      <dc:date>2008-10-03T15:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51648#M10873</link>
      <description>Thanks a lot for your feedback. &lt;BR /&gt;
&lt;BR /&gt;
I've two data sets&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
DS1&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
Var1     var2      var3      var4&lt;BR /&gt;
&lt;BR /&gt;
X          123       2345     324&lt;BR /&gt;
&lt;BR /&gt;
Y          234       3245     234&lt;BR /&gt;
&lt;BR /&gt;
Z          345       3456     314&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
DS2&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
Var1     var5      &lt;BR /&gt;
&lt;BR /&gt;
X          .98&lt;BR /&gt;
&lt;BR /&gt;
X          .87&lt;BR /&gt;
&lt;BR /&gt;
X          .86&lt;BR /&gt;
&lt;BR /&gt;
Y         .64&lt;BR /&gt;
&lt;BR /&gt;
Y         .65&lt;BR /&gt;
&lt;BR /&gt;
Y         .64&lt;BR /&gt;
&lt;BR /&gt;
Z          .09&lt;BR /&gt;
&lt;BR /&gt;
Z          .34&lt;BR /&gt;
&lt;BR /&gt;
Z          .87&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
I had merged these two files to get the resultant output with var6 var7 var8 (including 1 -5 ), that had to calculate Var1, 2, 3 with 5. During this operation I came across such a situation that repeated the o/p values. &lt;BR /&gt;
&lt;BR /&gt;
for this report it does not include var5 so I could suppress it with no repeated obs.&lt;BR /&gt;
 &lt;BR /&gt;
I need to create a report that includes var5 with all the values but also summarize the other vars with single obs.&lt;BR /&gt;
&lt;BR /&gt;
I would appreceate if you can come up with a solution to this.</description>
      <pubDate>Fri, 03 Oct 2008 16:44:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51648#M10873</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-03T16:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51649#M10874</link>
      <description>I want the report to look like this:&lt;BR /&gt;
&lt;BR /&gt;
Var1 	var2	var3	var4	var5	var6	var7&lt;BR /&gt;
X	123	2345	324	0.98	120.54	2298.1&lt;BR /&gt;
				 0.87		&lt;BR /&gt;
				 0.86		&lt;BR /&gt;
Y	234	3245	234	0.64	149.76	2076.8&lt;BR /&gt;
				 0.65		&lt;BR /&gt;
				 0.64		&lt;BR /&gt;
Z	345	3456	314	0.09	31.05	311.04&lt;BR /&gt;
				 0.34		&lt;BR /&gt;
				 0.87		&lt;BR /&gt;
&lt;BR /&gt;
Currently I’m getting it this way&lt;BR /&gt;
&lt;BR /&gt;
Var1 	var2	var3	var4	var5	var6	var7&lt;BR /&gt;
X	123	2345	324	0.98	120.54	2298.1&lt;BR /&gt;
X	123	2345	324	0.87	120.54	2298.1&lt;BR /&gt;
X	123	2345	324	0.86	120.54	2298.1&lt;BR /&gt;
Y	234	3245	234	0.64	149.76	2076.8&lt;BR /&gt;
Y	234	3245	234	0.65	149.76	2076.8&lt;BR /&gt;
Y	234	3245	234	0.64	149.76	2076.8&lt;BR /&gt;
Z	345	3456	314	0.09	31.05	311.04&lt;BR /&gt;
Z	345	3456	314	0.34	31.05	311.04&lt;BR /&gt;
Z	345	3456	314	0.87	31.05	311.04&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
SN

Message was edited by: liv4sas</description>
      <pubDate>Fri, 03 Oct 2008 17:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51649#M10874</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-03T17:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc print</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51650#M10875</link>
      <description>Hi:&lt;BR /&gt;
  Neither PROC PRINT nor PROC REPORT will produce a report that looks like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Var1  var2  var3  var4  var5  var6    var7&lt;BR /&gt;
X     123   2345  324   0.98  120.54  2298.1&lt;BR /&gt;
0.87 &lt;BR /&gt;
0.86 &lt;BR /&gt;
Y     234   3245  234   0.64  149.76  2076.8&lt;BR /&gt;
0.65 &lt;BR /&gt;
0.64 &lt;BR /&gt;
Z     345   3456  314   0.09  31.05   311.04&lt;BR /&gt;
0.34 &lt;BR /&gt;
0.87 &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
You may want to read up in the documentation on Data Step reporting, particularly, DATA _NULL_. If you want to write to the LISTING window, then investigate the program examples for FILE PRINT with PUT statements. If you want to write to ODS HTML, RTF or PDF destinations, then investigate the program examples for FILE PRINT ODS with PUT _ODS_.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 03 Oct 2008 19:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-print/m-p/51650#M10875</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-10-03T19:19:46Z</dc:date>
    </item>
  </channel>
</rss>

