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

dear all 

i have the data of 163 companies with their incorporate year  in the following format.

Company_NameIncorporation 
A C C Ltd.1936
A I A Engineering Ltd.1991
Adani Enterprises Ltd.1993
Adani Green Energy Ltd.2015
Adani Ports & Special Economic Zone Ltd.1998
Aditya Birla Fashion & Retail Ltd.2007
Ambuja Cements Ltd.1981
Apollo Hospitals Enterprise Ltd.1979
Apollo Tyres Ltd.1972
Ashok Leyland Ltd.1948
Asian Paints Ltd.1945
Aurobindo Pharma Ltd.1986
Avenue Supermarts Ltd.2000
Axis Bank Ltd.1993
Bajaj Auto Ltd.2007

 

i have to compute the age of each company in the following format from 2010 to 2021. it is to be computed as the number of years from the year of incorporation to the current year.

i  need it in the following format

Company_Nameyearage
A C C Ltd.201074
A C C Ltd.201175
A C C Ltd.201276
A C C Ltd.201377
A C C Ltd.201478
A C C Ltd.201579
A C C Ltd.201680
A C C Ltd.201781
A C C Ltd.201882
A C C Ltd.201983
A C C Ltd.202084
A C C Ltd.202185
A I A Engineering Ltd.201019
A I A Engineering Ltd.201120
A I A Engineering Ltd.201221
A I A Engineering Ltd.201322
A I A Engineering Ltd.201423
A I A Engineering Ltd.201524
A I A Engineering Ltd.201625
A I A Engineering Ltd.201726
A I A Engineering Ltd.201827
A I A Engineering Ltd.201928
A I A Engineering Ltd.202029
A I A Engineering Ltd.202130

 

please suggest me a suitable SAS code \

thanks in advance 

 

1 ACCEPTED SOLUTION

Accepted Solutions
maguiremq
SAS Super FREQ
data have;
infile datalines delimiter = ",";
input company_name :$50. incorporation 4.;
datalines;
A C C Ltd.,1936
A I A Engineering Ltd.,1991
Adani Enterprises Ltd.,1993
Adani Green Energy Ltd.,2015
Adani Ports & Special Economic Zone Ltd.,1998
Aditya Birla Fashion & Retail Ltd.,2007
Ambuja Cements Ltd.,1981
Apollo Hospitals Enterprise Ltd.,1979
Apollo Tyres Ltd.,1972
Ashok Leyland Ltd.,1948
Asian Paints Ltd.,1945
Aurobindo Pharma Ltd.,1986
Avenue Supermarts Ltd.,2000
Axis Bank Ltd.,1993
Bajaj Auto Ltd.,2007
;
run;

data want (drop = incorporation);
	set have;
	do year = 2010 to 2021;
		age = year - incorporation;
		output;
	end;
run;
company_name 	year 	age
A C C Ltd. 	2010 	74
A C C Ltd. 	2011 	75
A C C Ltd. 	2012 	76
A C C Ltd. 	2013 	77
A C C Ltd. 	2014 	78
A C C Ltd. 	2015 	79
A C C Ltd. 	2016 	80
A C C Ltd. 	2017 	81
A C C Ltd. 	2018 	82
A C C Ltd. 	2019 	83
A C C Ltd. 	2020 	84
A C C Ltd. 	2021 	85
A I A Engineering Ltd. 	2010 	19
A I A Engineering Ltd. 	2011 	20
A I A Engineering Ltd. 	2012 	21

 Not sure how you want to deal with those negative values, but you can easily subset it.

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

So A C C Ltd. should be computed from 1936 to 2021 right?

maguiremq
SAS Super FREQ
data have;
infile datalines delimiter = ",";
input company_name :$50. incorporation 4.;
datalines;
A C C Ltd.,1936
A I A Engineering Ltd.,1991
Adani Enterprises Ltd.,1993
Adani Green Energy Ltd.,2015
Adani Ports & Special Economic Zone Ltd.,1998
Aditya Birla Fashion & Retail Ltd.,2007
Ambuja Cements Ltd.,1981
Apollo Hospitals Enterprise Ltd.,1979
Apollo Tyres Ltd.,1972
Ashok Leyland Ltd.,1948
Asian Paints Ltd.,1945
Aurobindo Pharma Ltd.,1986
Avenue Supermarts Ltd.,2000
Axis Bank Ltd.,1993
Bajaj Auto Ltd.,2007
;
run;

data want (drop = incorporation);
	set have;
	do year = 2010 to 2021;
		age = year - incorporation;
		output;
	end;
run;
company_name 	year 	age
A C C Ltd. 	2010 	74
A C C Ltd. 	2011 	75
A C C Ltd. 	2012 	76
A C C Ltd. 	2013 	77
A C C Ltd. 	2014 	78
A C C Ltd. 	2015 	79
A C C Ltd. 	2016 	80
A C C Ltd. 	2017 	81
A C C Ltd. 	2018 	82
A C C Ltd. 	2019 	83
A C C Ltd. 	2020 	84
A C C Ltd. 	2021 	85
A I A Engineering Ltd. 	2010 	19
A I A Engineering Ltd. 	2011 	20
A I A Engineering Ltd. 	2012 	21

 Not sure how you want to deal with those negative values, but you can easily subset it.

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