dear all
i have the data of 163 companies with their incorporate year in the following format.
Company_Name | Incorporation |
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_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 |
A I A Engineering Ltd. | 2013 | 22 |
A I A Engineering Ltd. | 2014 | 23 |
A I A Engineering Ltd. | 2015 | 24 |
A I A Engineering Ltd. | 2016 | 25 |
A I A Engineering Ltd. | 2017 | 26 |
A I A Engineering Ltd. | 2018 | 27 |
A I A Engineering Ltd. | 2019 | 28 |
A I A Engineering Ltd. | 2020 | 29 |
A I A Engineering Ltd. | 2021 | 30 |
please suggest me a suitable SAS code \
thanks in advance
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.
So A C C Ltd. should be computed from 1936 to 2021 right?
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.