BookmarkSubscribeRSS Feed
JAR
Obsidian | Level 7 JAR
Obsidian | Level 7
HI All,
I have the follwing issue:

Product..Month.......Sales
x.......April.......10
y.......April.......5
x.......May.......12
y.......May.......12
x.......June.......15
y.......June.......14

I would like SAS do the the following:
Product.......Growth
x.......15-10
y.......14-5

In fact, for the data I have, i will be calculating yearly growth. And, the date values are all in date format itself.

Thaning you in advance,
Jijil
2 REPLIES 2
Ksharp
Super User
[pre]
data temp;
infile datalines dlm='.';
input Product $ Month : date9. Sales ;
format month monname.;
datalines;
x.......11Apr2009.......10
y.......12Apr2009.......5
x.......14May2009.......12
y.......15May2009.......12
x.......16Jun2009.......15
y.......17Jun2009.......14
;
run;
proc sort data=temp;
by product month ;
run;
data want;
set temp;
by product month;
length growth $ 10;
retain start;
if first.product then start=sales;
if last.product then do;
growth=catx('-',sales,start);
output;
end;
keep product growth;
run;
[/pre]
Ksharp
JAR
Obsidian | Level 7 JAR
Obsidian | Level 7
Dear Ksharp:
Thanks a lot for the code.
I had instered those dots as this forum does not support tab. Anyway, you code works awesome!

Finally, I wanted the actual numerical value instead of 15-10, which is not difficult.

Thanks a million!

Jijil Ramakrishnan

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
  • 2 replies
  • 844 views
  • 0 likes
  • 2 in conversation