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

Hi,

Time series data (CPI, for example) are often indexed to a specific base year such that the value in that year is 1 (or 100) and the values in other years are expressed as ratios to the base year value.  I would like to re-base (or re-index) my series to a new base year which simply involves dividing each value by the value in my desired base year.  The difficulty is that for the early years, I need to know the value in that later, base year.  Does anyone know if there's a simple way to do this (i.e. without getting in to macro programming)?

 

Thank you all!

 

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

Hello,

 

An other possible solution :

 

 

data want;
	retain base;

	if _N_=1 then do;
		set have (where=(year=2004));
		base=val;
	end;

	set have;
	index_val=val/base;

	drop base;
run;

 

View solution in original post

4 REPLIES 4
ChrisBrooks
Ammonite | Level 13

You simply select the base year value into a macro variable first and use it in your data step like this

 

 

data have;
	input year val;
	datalines;
2000 50
2001 60
2002 70
2003 75
2004 90
2005 100
2006 120
2007 150
2008 155
2009 200
;
run;

/* Store the base year value in a macro variable */

proc sql;
	select val into :base_val
	from have
	where year =2004;
quit;

data want;
	set have;
	index_val=val/&base_val;
run;
gamotte
Rhodochrosite | Level 12

Hello,

 

An other possible solution :

 

 

data want;
	retain base;

	if _N_=1 then do;
		set have (where=(year=2004));
		base=val;
	end;

	set have;
	index_val=val/base;

	drop base;
run;

 

flyingbear
Fluorite | Level 6
Thanks! This is very instructive regarding the data step -- helpful for this problem and in the future.
flyingbear
Fluorite | Level 6

Thanks very much!

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
  • 4 replies
  • 845 views
  • 1 like
  • 3 in conversation