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

 

 

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!

1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12

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.

View solution in original post

4 REPLIES 4
japelin
Rhodochrosite | Level 12

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?

igsteo
Calcite | Level 5
Example:
mktweight16=m16/mktcap16
by stock

i will carry this out for data from 2016 - 2020
japelin
Rhodochrosite | Level 12

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.

igsteo
Calcite | Level 5
thank you so much!

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 876 views
  • 0 likes
  • 2 in conversation