BookmarkSubscribeRSS Feed
mona4u
Lapis Lazuli | Level 10

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..
10 REPLIES 10
Reeza
Super User

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

mona4u
Lapis Lazuli | Level 10

I gonna create a report in another step 

but I need to sum those variables to create a histogram  

 

Reeza
Super User

@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...

mona4u
Lapis Lazuli | Level 10

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

mona4u
Lapis Lazuli | Level 10

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?  

 

Reeza
Super User

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


 

mona4u
Lapis Lazuli | Level 10

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

ballardw
Super User

@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.

mona4u
Lapis Lazuli | Level 10

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

 

Reeza
Super User
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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 951 views
  • 2 likes
  • 3 in conversation