BookmarkSubscribeRSS Feed
kumarK
Quartz | Level 8

I have data like this

Branch year sales

india 2009 1mn

india 2010 1.2mn

nepal 2008 0.5mn

nepal 2009 1mn

...;

like that i have many countries

i want , average rate of growth of sales for each branch by year wise. Please suggest some logics.

3 REPLIES 3
Patrick
Opal | Level 21

Hi Kumar

In my understanding this forum provides quality support to people who get stuck with a problem and need help. What this forum is not about is doing the work for you.

I suggest you first give it a go and then come back if you can't solve the problem by yourself. You then give us sample data (a data step generating this data so we don't have to do the work), and explanation what you have and what you want, and a sample of how the "what you want" looks like.

If you already developed some code (may be not working) then post this code as well. This will help us to better understand where you are at and where you might need some help.

Thanks

Patrick

PGStats
Opal | Level 21

What should the output look like for input

Branch year salesMn

india 2009 1

india 2010 1.2

india 2011 1.1

nepal 2008 0.5

nepal 2009 1

  

PG

PG
venkatnaveen
Obsidian | Level 7

Here is the answer.

First convert into numeric variable sales using input function and use compress function to replace alphabets from value and then use proc sql.

Here is the code.

Correct me if I am wrong

data ds1;

infile cards;

input

Branch $ year sales $;

cards;

india 2009 1mn

india 2009 2mn

india 2010 1.2mn

nepal 2008 0.5mn

nepal 2009 1mn

;

data ds2;

set ds1;

sales1=compress(sales,'','a');

numeric=input(sales1,8.);

drop sales;

run;

proc sql;

create table demo as

select Branch,year,avg(numeric)as sales from ds2 group by Branch,year ;

quit;

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
  • 764 views
  • 0 likes
  • 4 in conversation