Help using Base SAS procedures

calculate the No of observation

Accepted Solution Solved
Reply
Contributor
Posts: 72
Accepted Solution

calculate the No of observation

I have data which contain 9 countries, Year from 2006-2010, Fam is a variable which has value 0 for non fam and  1 for fam

I want to calculate No of Observations in the following format

Country         Fam      Non fam        total

HKG

KOR

and here is my data.

 

data work.new;
infile datalines dsd truncover;
input Global_Company_Key:32. SICC:32. CoName:$255. company:$255. fam:32. Country:$255. year:32.;
datalines;
200687,7370,BEIJING DEVELOPMENT (HK) LTD,BEIJING DEVELOPMENT,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
200687,7370,BEIJING DEVELOPMENT (HK) LTD,BEIJING DEVELOPMENT,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
200687,7370,BEIJING DEVELOPMENT (HK) LTD,BEIJING DEVELOPMENT,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
200687,7370,BEIJING DEVELOPMENT (HK) LTD,BEIJING DEVELOPMENT,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
200687,7370,BEIJING DEVELOPMENT (HK) LTD,BEIJING DEVELOPMENT,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
202779,4922,BEIJING ENTERPRISES HOLDINGS,BEIJING ENTERPRISES,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
202779,4922,BEIJING ENTERPRISES HOLDINGS,BEIJING ENTERPRISES,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
202779,4922,BEIJING ENTERPRISES HOLDINGS,BEIJING ENTERPRISES,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
202779,4922,BEIJING ENTERPRISES HOLDINGS,BEIJING ENTERPRISES,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
202779,4922,BEIJING ENTERPRISES HOLDINGS,BEIJING ENTERPRISES,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
282713,2070,CHINA AGRI INDUS HOLDINGS,CHINA AGRI PRODUCTS,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
282713,2070,CHINA AGRI INDUS HOLDINGS,CHINA AGRI PRODUCTS,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
282713,2070,CHINA AGRI INDUS HOLDINGS,CHINA AGRI PRODUCTS,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
282713,2070,CHINA AGRI INDUS HOLDINGS,CHINA AGRI PRODUCTS,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
282713,2070,CHINA AGRI INDUS HOLDINGS,CHINA AGRI PRODUCTS,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
16538,4512,CATHAY PACIFIC AIRWAYS LTD,CHINA METAL INTN'L,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
16538,4512,CATHAY PACIFIC AIRWAYS LTD,CHINA METAL INTN'L,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
16538,4512,CATHAY PACIFIC AIRWAYS LTD,CHINA METAL INTN'L,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
16538,4512,CATHAY PACIFIC AIRWAYS LTD,CHINA METAL INTN'L,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
220407,3600,CHINA AEROSPACE INTL HLDGS,CHINA METAL INTN'L,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
220407,3600,CHINA AEROSPACE INTL HLDGS,CHINA OVERSEAS LAND,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
220407,3600,CHINA AEROSPACE INTL HLDGS,CHINA OVERSEAS LAND,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
220407,3600,CHINA AEROSPACE INTL HLDGS,CHINA OVERSEAS LAND,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
220407,3600,CHINA AEROSPACE INTL HLDGS,CHINA OVERSEAS LAND,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
201218,4991,CHINA EVERBRIGHT INTL LTD,CHINA OVERSEAS LAND,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
201218,4991,CHINA EVERBRIGHT INTL LTD,CHINA OVERSEAS PROP,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
201218,4991,CHINA EVERBRIGHT INTL LTD,CHINA OVERSEAS PROP,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
201218,4991,CHINA EVERBRIGHT INTL LTD,CHINA OVERSEAS PROP,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
65662,4812,CHINA MOBILE LTD,CHINA OVERSEAS PROP,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
65662,4812,CHINA MOBILE LTD,CHINA OVERSEAS PROP,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
259199,4991,CHINA RES PWR HLDG,CHINA RESOURCES LAND,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
259199,4991,CHINA RES PWR HLDG,CHINA RESOURCES LAND,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
259199,4991,CHINA RES PWR HLDG,CHINA RESOURCES LAND,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
259199,4991,CHINA RES PWR HLDG,CHINA RESOURCES LAND,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
259199,4991,CHINA RES PWR HLDG,CHINA RESOURCES LAND,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
65662,4812,CHINA MOBILE LTD,CHINA TAIPING INSU,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
162077,4813,CHINA NETCOM GROUP CORP,CHINA TAIPING INSU,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
162077,4813,CHINA NETCOM GROUP CORP,CHINA TAIPING INSU,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
102106,4991,CHINA POWER INTERNATIONAL,CHINA TAIPING INSU,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
102106,4991,CHINA POWER INTERNATIONAL,CHINA TAIPING INSU,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,CITIC RESOURCES,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,CITIC RESOURCES,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,CITIC RESOURCES,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,CITIC RESOURCES,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,CITIC RESOURCES,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
142540,1311,CNOOC LTD,CNOOC LTD,0,HKG,2009,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
142540,1311,CNOOC LTD,CNOOC LTD,0,HKG,2010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
142540,1311,CNOOC LTD,CNOOC LTD,0,HKG,2007,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
142540,1311,CNOOC LTD,CNOOC LTD,0,HKG,2008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
142540,1311,CNOOC LTD,CNOOC LTD,0,HKG,2006,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;;;;


Accepted Solutions
Solution
‎11-10-2016 02:34 AM
Super User
Posts: 18,569

Re: calculate the No of observation

http://www.ats.ucla.edu/stat/sas/modules/descript.htm

 

Thats is why I included links to video and code tutorials. 

 

You've been asking questions but not seeming to progress with your SAS skills. Is your intention to learn or simply have someone provide you a solution via code? 

View solution in original post


All Replies
Super User
Posts: 18,569

Re: calculate the No of observation

Contributor
Posts: 72

Re: calculate the No of observation

dont know proc freq
Solution
‎11-10-2016 02:34 AM
Super User
Posts: 18,569

Re: calculate the No of observation

http://www.ats.ucla.edu/stat/sas/modules/descript.htm

 

Thats is why I included links to video and code tutorials. 

 

You've been asking questions but not seeming to progress with your SAS skills. Is your intention to learn or simply have someone provide you a solution via code? 

Contributor
Posts: 72

Re: calculate the No of observation

I am learning. Its coding is complex. sometime i even spend days to learn simple thing but couldnt.
Super User
Posts: 18,569

Re: calculate the No of observation

There's the free SAS e course if you're interested. Takes 3 days full time but you can complete it at your leisure. 

 

http://support.sas.com/training/tutorial/

 

 

Super User
Posts: 10,871

Re: calculate the No of observation

The data you posted looks very much like it was a CSV created from Excel. Knowing enough to convert to CSV is a very good thing.

But I caution you to be very careful as Excel can have issues with exporting data depending on how it was entered or created. Values, such as product identifiers sometimes have aritmetic applied if the value has a - in it and Dates can be very problematic as to output format.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 212 views
  • 1 like
  • 3 in conversation