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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.