Write and run SAS programs in your web browser

sum function or sum statement

Reply
Regular Contributor
Posts: 161

sum function or sum statement

I'm trying to get the sum of the Site_Approved2 and Date_Supplied3  by using the sum function or sum statement on SAS studio but nothing worked with me 

please advise me on that. 

 

here is my data 

 Obs Sites_Contracted site_number1 Site_Approved1 Date_Supplied312345678910111213141516171819202122232425262728293031323334353637

341000..
341001..
3410501.
341100.1
34120011
34125011
341252..
341300..
341350.1
341351..
341400..
341401..
341450..
3414511.
341452..
341453..
341500..
3416001.
34160111
341602..
341700.1
341750..
345000..
345002..
345003..
345003..
345003..
345003..
345003..
345003..
345003..
345004..
345005..
345006..
345007..
345008.1
345009..
Super User
Posts: 23,771

Re: sum function or sum statement

Neither, use a summary procedure such as MEANS, SUMMARY, UNIVARIATE, SQL or PROC TABULATE

 

See an example here:

 

https://github.com/statgeek/SAS-Tutorials/blob/master/proc_means_basic.sas

Regular Contributor
Posts: 161

Re: sum function or sum statement

[ Edited ]

I gonna create a report in another step 

but I need to sum those variables to create a histogram  

 

Super User
Posts: 23,771

Re: sum function or sum statement


mona4u wrote:

I gonna create a report in another step 

but I need to sum those variables to create a histogram  

 


What makes you think that? Did you try creating a histogram with the raw data? And what does that have to do with my suggestion of using PROC MEANS/SUMMARY?

 

I would suggest you look at PROC UNIVARIATE and the HISTOGRAM statement within it. There's a lot of examples within the documentation that align with what you're trying to do.

 

http://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.2&docsetId=procstat&docsetTarget=proc...

Regular Contributor
Posts: 161

Re: sum function or sum statement

Bc Proc Univariate creates too many things that I don't need to include in my report

Regular Contributor
Posts: 161

Re: sum function or sum statement

I need to create a simple histogram like this after getting the total of each variable to insert it after the table that I created it by proc report 

. So, I what I need to know is how to create a histogram from the total of those variable and how to insert it in proc report?  

 

Super User
Posts: 23,771

Re: sum function or sum statement

You can control what is included in the output and have no output as well. And PROC MEANS is how you would create that summary anyways. 

 

https://blogs.sas.com/content/iml/2015/05/26/suppress-ods.html

 

The first example I demonstrated doesn't create any output because it used NOPRINT but did create the summary statistics. Did you try running that code? It' uses the data sets from SASHELP so you can run it directly in your session.

 


mona4u wrote:

Bc Proc Univariate creates too many things that I don't need to include in my report


 

Regular Contributor
Posts: 161

Re: sum function or sum statement

I'm bias about proc report for some reasons  and I need to know how possible is create a histogram or chart there 

Super User
Posts: 13,583

Re: sum function or sum statement


mona4u wrote:

I'm bias about proc report for some reasons  and I need to know how possible is create a histogram or chart there 


Proc report doesn't do graphics. Proc report will create output datasets but you still need to send the data to a graphics procedure.

Regular Contributor
Posts: 161

Re: sum function or sum statement

tell me how to do the graph before proc report and how to output the graph along with the table in the proc report. 

 

Highlighted
Super User
Posts: 23,771

Re: sum function or sum statement

ods excel file='C:\_localdata\temp.xlsx' style=meadow options(sheet_interval='none');
title 'My Histogram';
proc sgplot data=sashelp.class;
histogram height;
run;

title 'My Proc Report';
proc report data=sashelp.class;
column sex age;
define sex / group;
define age / across;
run;

ods excel close;
Ask a Question
Discussion stats
  • 10 replies
  • 136 views
  • 2 likes
  • 3 in conversation