BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Karan_Dumbre
Calcite | Level 5

the below is the data set. and i need to compute the  countries which have highest and lowest Amount

so anyone can help me

and another question is to create a report to have Country wise Category based sum of Amount

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisBrooks
Ammonite | Level 13

First do a proc Means to get your totals into an output data set

 

proc means data=product sum;
	class country;
	var amount;
	output out=summary(where=(_type_=1)) sum=total;
run;

Then to get the maximum and minimum

 

proc sql;
	select country, total
	from summary
	having total=max(total) or total=min(total);
quit;

A simple report can be generated with Proc Print

 

proc print data=summary;
	var country total;
	title "Country Totals";
run;

Of course much more elaborate reports can be produced with SAS but as you give no further details I've just shown the simplest method 🙂

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Without having opened your data, do something like this and adjust the class variables to your liking.

 

proc means data=product sum;
	class Country;
	var Amount;
run;
Karan_Dumbre
Calcite | Level 5

i want which country has the highest amount n lowest amount

 i tried sorting the data set and display the first obs which is the lowest n last obs

ChrisBrooks
Ammonite | Level 13

First do a proc Means to get your totals into an output data set

 

proc means data=product sum;
	class country;
	var amount;
	output out=summary(where=(_type_=1)) sum=total;
run;

Then to get the maximum and minimum

 

proc sql;
	select country, total
	from summary
	having total=max(total) or total=min(total);
quit;

A simple report can be generated with Proc Print

 

proc print data=summary;
	var country total;
	title "Country Totals";
run;

Of course much more elaborate reports can be produced with SAS but as you give no further details I've just shown the simplest method 🙂

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 1901 views
  • 0 likes
  • 3 in conversation