Variables in totalmktcap: mktcap16--mktcap20
Variables in decme2_all: stock me16--me20
I am trying to calculate the weightage of every stock per year i.e. from 2016 to 2020. However, that means dividing values from two different data sets. I need help to code this. It would be much appreciated
Thank you everyone!
Try this code.
proc sql;
create table have as
select * from totalmktcap, decme2_all;
;
quit;
data want;
set have;
array mw{*} mktweight16-mktweight20;
array me{*} me16-me20;
array mk{*} mktcap16-mktcap20;
do i=1 to dim(mw);
mw{i}=me{i}/mk{i};
end;
drop i;
run;
I don't have the data set, so I haven't tested it yet.
The response will vary depending on what kind of calculation you want to do.
rename, merge, or...
Can you give us a specific calculation using the variable name?
Try this code.
proc sql;
create table have as
select * from totalmktcap, decme2_all;
;
quit;
data want;
set have;
array mw{*} mktweight16-mktweight20;
array me{*} me16-me20;
array mk{*} mktcap16-mktcap20;
do i=1 to dim(mw);
mw{i}=me{i}/mk{i};
end;
drop i;
run;
I don't have the data set, so I haven't tested it yet.
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.