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

I want to make following table. excel file is attached with this . fam is 0 for non-family firms while fam is 0 for family firms. 

Country JPN
                                         Book deb ratio
                               N    mean   median  max  min
 Family firms
Non-family firms
 
Country Kor                         Book deb ratio
                               N    mean   median  max  min
 Family firms
Non-family firms
 
1 ACCEPTED SOLUTION
11 REPLIES 11
Kurt_Bremser
Super User

Try this:

(added my own datastep, as I never open Office files from the web)

data have;
input country $ fam bdr;
cards;
JPN 0 5
JPN 0 6
JPN 1 3
JPN 1 4
KOR 0 3
KOR 0 2
KOR 1 4
KOR 1 5
;
run;

proc summary data=have;
var bdr;
class fam;
by country;
output
  out=want (
    drop=_type_
    rename=(_freq_=N)
    where=(fam ne .)
  )
  mean(bdr)=mean
  median(bdr)=median
  max(bdr)=max
  min(bdr)=min
;
run;
Jahanzaib
Quartz | Level 8

Thanks for your reply but it do not explain the things that i want. because it only work for the mentioned countries and inclue only 5 observations. anyone here who can open my excel file and explain in more detail?

Klara
Calcite | Level 5

Maybe this...?

 

Proc sort data=your.data;

by country;

run;

 

proc means data=your.data  n mean median max min;

var ...;

class fam;

by country;

run;

Ksharp
Super User

It is easy for proc tabulate.

 

proc import datafile='/folders/myfolders/22.xls' out=have replace dbms=xls;run;
data temp;
 set have;
 length F $ 20;
 if Fam=0 then F='Non-family firms';
  else if Fam=1 then F='Family firms';
run;
options nobyline;
title j=l "Country #byval1";
proc tabulate data=temp;
by count;
var book_debt_ratio;
class F;
table F=' ',book_debt_ratio*(N    mean   median  max  min);
run;
Jahanzaib
Quartz | Level 8

when i put the complete data which contain 9 countries than it comes up with this error. 

 

ERROR: Data set WORK.TEMP is not sorted in ascending sequence. The current BY group has Count =
JPN and the next BY group has Count = HKG.

Jahanzaib
Quartz | Level 8

I want to merge two data's. in both excel files the company name are same i have data for 14 years so i want to merge two files in a sense that company name and data for a particular year apear togather.  for example i have stock data for 100 companies for 14 years is in one file and total assets data for those 100 companies for 14 years is another file. how can i merge these two files.  both the files contain same companies names and same years. Thanks in anticipation.

Klara
Calcite | Level 5

Before any using of BY statement, the data set has to be sorted:

Proc sort data=your.data;

by country;

run;

Jahanzaib
Quartz | Level 8

I have got my results in the form 10.02 i want to get the results upto 4 points. can you describe how can i take this upto four point like 10.02 to 10.0214

Kurt_Bremser
Super User

Add a format to the variable, like this:

proc summary data=have;
var bdr;
class fam;
by country;
attrib bdr format=10.4;
output
  out=want (
    drop=_type_
    rename=(_freq_=N)
    where=(fam ne .)
  )
  mean(bdr)=mean
  median(bdr)=median
  max(bdr)=max
  min(bdr)=min
;
run;

The format will be inherited by the statistics.

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
  • 11 replies
  • 4152 views
  • 1 like
  • 4 in conversation