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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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