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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.