BookmarkSubscribeRSS Feed
Jahanzaib
Quartz | Level 8

I want to calculate No and percentage of firms for each country. (each firm is repeated by many time due to its data for several years)

My data contain several countries from year 2000 to 2015.

there is dummy variable of fam which is 0 for non family and 1 for family.

i want to make table in this format. These are just hypothetical values for reference.  the attached file contain excel data in excel and cvs format. here percentage means percentage of family firms and non-family firms to overall sample firms. 

 Country       Fam            Non family

 HKG             50                 80

                      6%                9%               

 IDN               70                 110

                      7%                 11%

6 REPLIES 6
Jahanzaib
Quartz | Level 8

you mean i need to post example data in SAS file format?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Follow the instructions in this post to get a datastep text you can copy and paste into the text box:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

Jahanzaib
Quartz | Level 8

I tried to understand this but couldn't get the explanation. 

Ksharp
Super User

Post your data at this forum. No one would like to download a file from website.



proc import datafile='/folders/myfolders/new.csv' out=have dbms=csv replace;
run;
proc format;
value fmt
 0-1=[percent8.2];
value fam
 0='Non_Fam'
 1='Fam';
run;
proc sql;
create table temp as
 select 1 as group,country,fam,count(distinct company) as v
  from have
   where country is not missing
    group by country,fam
union all
 select 2 as group,country,fam,
 count(distinct company)/(select count(distinct company) from have) as v 
  from have
   where country is not missing
    group by country,fam
order by 2,1  
;
quit;
proc transpose data=temp out=want(drop=_: group);
 by country group;
 var v;
 id fam;
 format fam fam.;
run;
data want;
 set want;
 format _numeric_ fmt.;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 1422 views
  • 3 likes
  • 4 in conversation