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

Hy friends

i have uploaded a file with this post kindly check this i need to calculate few variables please help me i have to submit my class assignment and i am not coming up with these thanks a lot

a) 5CR= share of 5 largest bank asset (useing TA in the file)/ Total Asset in the Market (TMA)

i need to calculate the sum of 5 largest banks in each country in each year ????? please provide some codes

2) HHI= Sigma (MS) sequre

i can calculate this by using command like

data temp1;

MS2=MS*MS;

run;

calculation of sum...

proc Means Sum;

var MS2;

by Year;

run;

this give me output file but i do not know how can i get this is sas data file like i have uploaded here to include this in my final data set. kindly provide me any procedure to export this into excel or other file so that i can run some test on this ... i will be very thankful to you for this kindness

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

OH. That is easy.

proc sql;

create table two as

   select country,year,sum(ms**2) as hhi

    from have

    group by country,year ;

quit;

About your question, go and ask

Cynthia@sasCynthia@sas

She is an excellent SAS programming trainer . But if you want become an seasoned programmer, stick with this community and work with us.


Good Luck.

Xia Keshan

Ksharp


View solution in original post

6 REPLIES 6
Ksharp
Super User

How about :



proc import datafile='c:\temp\Datafile.xls' out=have dbms=excel replace;run;


proc sql;
 create table temp as
  select *, ta/tma as _5cr ,sum(ms**2) as hhi
   from have
    group by year
     order by country,year,_5cr desc;
quit;

data want;
 set temp;
 by country year ;
 if first.year then n=0;
 n+1;
 if n lt 6;
 drop n;
run;


Xia Keshan

raqthesolid
Quartz | Level 8

i appreciate your prompt response but it is different from what i want.

proc sql;

create table temp as

  select *, ta/tma as _5cr ,sum(ms**2) as hhi

   from have

    group by year

     order by country,year,_5cr desc;

quit;

1) need to sort the data by country and Bank

thank sum the five largest bank in each year

thank sum of five largest bank/ TMA (same year)

for HHI

1)

square of Market share of each firm

then add the firms in each year like for 1999 one value which i call as Sumation or Sigma (MS) square

I shall be very thankful if you could do this for me.

thanks for your valuable response

Ksharp
Super User

Still hard to catch you. Does it make some sense ?



proc import datafile='c:\temp\Datafile.xls' out=have dbms=excel replace;run;

proc sort data=have;by country year descending ta ;run;
data top5;
 set have;
 by country year ;
 if first.year then n=0;
 n+1;
 if n lt 6;
 drop n;
run;

proc sql;
 create table one as
  select country,year,sum(ta/tma) as _5cr 
   from top5
    group by country,year ;

 create table two as
   select year,sum(ms**2) as hhi
    from have
      group by year;
quit;

Xia Keshan

raqthesolid
Quartz | Level 8

Thanks its really a great help from your side. the 1st one is exactly the same as i wanted but second is on the basis of country , actually i want it in the same way as you calculated first like country than in each country specific value for each year..

Please write something for this two also recommend me some material to learn sas i am beginner..

Thanks a lot

Ksharp
Super User

OH. That is easy.

proc sql;

create table two as

   select country,year,sum(ms**2) as hhi

    from have

    group by country,year ;

quit;

About your question, go and ask

Cynthia@sasCynthia@sas

She is an excellent SAS programming trainer . But if you want become an seasoned programmer, stick with this community and work with us.


Good Luck.

Xia Keshan

Ksharp


raqthesolid
Quartz | Level 8

Thanks a lot for your help

you wish you good luck in life..

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 2037 views
  • 6 likes
  • 2 in conversation