Help using Base SAS procedures

RE: Mean, Median, Max, Min

Reply
Contributor
Posts: 60

RE: Mean, Median, Max, Min

Hi everyone

If I have a bunch of data from 1990-2000, with various variables say: Individual. Size of salary, Years of education,

Is it possible in SAS to choose a single year (lets say 1995) and a variable (size of salary) then run a command to obtain the mean, median, maximum and minimum salaries for the given year?

If so, thats great, what shouuld I be typing?

Super User
Posts: 10,020

Re: RE: Mean, Median, Max, Min

Posted in reply to spraynardz90

I think you should post some sample data to clarify your question . Are they lots of datasets when you refer to 1995-2012?

data _2011;
input Individual Size_of_salary Years_of_education ;
cards;
Kmart    2001    68,945    003144    KO
Kmart    2002    69,637    003144    KO
Kmart    2003    70,453    003144    KO
Kmart    2004    67,394    003144    KO
Kmart    2005    67,525    003144    KO
Kmart    2006    67,000    003144    KO
Kmart    2007    65,324    003144    KO
Kmart    2008    66,667    003144    KO
Kmart    2009    68,734    003144    KO
Kmart    2010    70,452    003144    KO
Kmart    2011    71,861    003144    KO
Kappa    2001    18    003144    Ky
Kappa    2002    20    003144    Ky
Kappa   2003    15    003144    Ky
Kappa   2004    21   003144    Ky
Kappa    2005    16    003144    Ky
Kappa    2006    17    003144    Ky
Kappa    2007    14    003144    Ky
Kappa    2008    20    003144    Ky
Kappa    2009    21    003144    Ky
Kappa    2010    16    003144    Ky
Kappa    2011    18   003144    Ky
;
run;
data _2012;
input Individual Size_of_salary Years_of_education ;
cards;
Kmart    2001    68,945    003144    KO
Kmart    2002    69,637    003144    KO
Kmart    2003    70,453    003144    KO
Kmart    2004    67,394    003144    KO
Kmart    2005    67,525    003144    KO
Kmart    2006    67,000    003144    KO
Kmart    2007    65,324    003144    KO
Kmart    2008    66,667    003144    KO
Kmart    2009    68,734    003144    KO
Kmart    2010    70,452    003144    KO
Kmart    2011    71,861    003144    KO
Kappa    2001    18    003144    Ky
Kappa    2002    20    003144    Ky
Kappa   2003    15    003144    Ky
Kappa   2004    21   003144    Ky
Kappa    2005    16    003144    Ky
Kappa    2006    17    003144    Ky
Kappa    2007    14    003144    Ky
Kappa    2008    20    003144    Ky
Kappa    2009    21    003144    Ky
Kappa    2010    16    003144    Ky
Kappa    2011    18   003144    Ky
;
run;

%let year=2012;
%let var=size_of_salary;


proc means data=_&year min max mean median ;
var &var ;
run;

Ksharp

Contributor
Posts: 60

Re: RE: Mean, Median, Max, Min

individualincome ppyears edproductivity nosavingsno. shares owneddebt
CALGENE INC104623.63053525.28823267.015512.9876658.591
ECOSCIENCE CORP/DE773212.30836812.78062738.2131256.35421792.24
OPTIMAX INDUSTRIES INC768620.81137520.2394682.1142.28732.614
BIOTECHNICA INTL INC182873.2022182.29143.23851.4720
MARGO CARIBE INC110821.3026411.758674.07832.864194.929
ML MACADAMIA ORCHARDS  -LP695342.31322827.13944165527.2414459
MYCOGEN CORP114504.76239612.0164340.715105.572.411
CHAI NA TA CORP781362.9489553.61812900.99889.4662726.662
NORTHLAND CRANBERRIES  -CL A116143.08117612.0042363.37664.15316.973
ALICO INC117903.5021881.3803034.774448
SYLVAN INC762644.24619326.1076473.3246.127341.043
DELTA & PINE LAND CO792554.2124536.184253.35427.7220
DEKALB GENETICS CORP  -CL B120065.76832115.696779.31520.2630.239
SAVIA SA DE CV801976.1681910.849232.61251.69732.957
PIONEER HI-BRED INTERNATIONL630967.2989130.105717.89653.9310
SUNAIR SERVICES CORP370220.91428913.452317.50384.8250.841
VCA ANTECH INC770563.74320211.663267.96744.78537.726
BAREFOOT INC770224.55343571.1334109.561.7982482.2
SERVICEMASTER CO711168.0014248.441943.79234.6339.151
POPE RESOURCES/DE  -LP770123.4182514.48847.04527.4051.139
RAYONIER TIMBERLANDS  -LP686625.13016.169835.53117.608
IP TIMBERLANDS  -LP-CL A672725.9117263.302199.78118.1856.219
KAT EXPLORATION INC808422.20992125.690952.34414.6094.988
NORD RESOURCES CORP662884.2696140.28697058.20511.5
KWG RESOURCES INC810920.59663610.83541.8528.9510.662
NORD PACIFIC LTD787262.4241830.1174.10732.2832.632
O'OKIEP COPPER CO  -ADR348843.9363064.460231.45222.06966.474
BENGUET CORP240294.8550492.06228.4641014.522
CLIFFS NATURAL RESOURCES INC274225.9388553.932711.47424.1760.557
COMINCO LTD306727.00118322.9577047.4240
FREEPORT-MCMORAN COP&GOLD752947.1002616.508122.1529.7881.681
CYPRUS AMAX MINERALS CO871277.933088.465192.95536.4573.881
RIO TINTO GROUP (GBP)762218.1960094.50884.7419.2361.712
ANGLO AMERICAN PLC143827.6002380.09254.55557.08133.079
PEGASUS GOLD INC753095.4538161.6764.43726.50610.378
HECLA MINING CO326514.8578492.19113.53126.5339.884
AMERICAN RESOURCE CORP INC799390.59773717.1554105.69133.3793.461
AMAX GOLD INC751114.5496579.55261.29630.0420
MERIDIAN GOLD INC750584.1489752.33131.89121.3720
GOLDEN STAR RESOURCES LTD79636-0.544730.392.89623.9831.779
REAL DEL MONTE MINING CP769392.7000850.6683.4123.4821.631
BLYVOORUITZICHT GOLD MINING185434.2041417.240335.39616.096117.114
STANDARD MINING CORP79816-1.594552.32125.52332.01829.533
VISTA GOLD CORP694463.9969520.2171.60541.9067.663
GREAT CENTRAL MINES NL790301.07055619.2858130.57322.63516.337
GREENSTONE RESOURCES LTD786951.5587761.48212.57820.8280.921
DAKOTA MINING CORP758832.1332196.168210.54318.2822.903
CAMBIOR INC807065.6985251.527810.45850.6317.697
SKY SCIENTIFIC INC76460-3.352414.4993.88519.1283.01
AMERICAN PAC MINERALS LTD772410.190621.25581.30822.1740.306
SILVERADO GOLD MINES LTD783650.41607510.33284.617.3537.021
USMX INC791512.6111720.191719.547233.6845.296
SISKON GOLD CORP  -CL A76986-1.5702226.569534.3599.80310.062
REA GOLD CORP785580.38662226.569534.3599.80310.062
EL CONDOR RESOURCES LTD78774-3.079117.206717.53826.2020
AMERICANA GLD&DIAMOND HLDGS80110-1.4740310.9601141.54162.00313.403
COMMERCE GROUP CORP57656-2.74887113.210115.151.7612.349
NORTHGATE MINERALS CORP499550.8241753.60634.737.4780
ALTA GOLD CO706912.369870.57281.27919.0960
CANYON RESOURCES CORP100422.9745094.799124.5831.7172.478
MK RESOURCES CO799973.66540610.5572236.833.380
CUSAC GOLD MINES LTD782712.04898214.175750.76224.79922.564
CALEDONIA MINING CORP775632.6836893.338266.55948.0820
CAMPBELL RESOURCES INC301543.848872.4314.11923.1670
GOLDEN KNIGHT RESOURCES INC785353.0512140.099210.44112.4846
GLAMIS GOLD LTD784953.9596322.83737.79139.44911.595
GETCHELL GOLD CORP118494.5554553.58353.17935.2830.617
WHARF RESOURCES LTD784674.0141464.14672.43415.020
AGNICO EAGLE MINES LTD782234.38377517.426610.5981495.821
ECHO BAY MINES LTD655685.9338351.37049.32413.4762.743
BATTLE MOUNTAIN GOLD CO858695.4366435.871219.70415.2660
GOLDCORP INC699054.94835621.63715.48826.1240
KINROSS GOLD CORP783954.8349876.08274.62613.050.462
ROYAL OAK MINES INC768095.0882810.764849.889114.6830.154
NEWMONT MINING CORP212076.3925370.17682.83524.70
NEWMONT GOLD CO695856.3925372.42996.28417.7260
BUFFELSFONTEIN GOLD MINES196695.6560652.53091.38311.4871.024
HOMESTAKE MINING123196.4862460.11352.59521.6950.243
SANTA FE PACIFIC GOLD CORP806945.9285350.21421.17829.0160.355
HEMLO GOLD MINES INC773065.5395173.943844.210.018
WESTERN DEEP LEVELS LTD822116.1636120.58721.28140.7710
PLACER DOME INC751816.8012832.9265.98312.0410.872
FREE STATE CONSOL GOLD MINES100607.1403782.60042.46320.9360
ANGLOGOLD ASHANTI LTD798996.7689622.37062.92411.0070
KLOOF GOLD MINING CO LTD479346.3142421.53821.61922.5230
GOLD FIELDS LTD307966.56263614.629744.32326.590
BARRICK GOLD CORP712986.8417222.38637.62812.5550.829
COEUR D'ALENE MINES CORP244414.5111121.66872.06212.6620.087
NORTH AMERICAN PALLADIUM798533.0334131.05371.20763.6490
URANIUM RESOURCES INC756722.852670.92743.14530.5690.01
STILLWATER MINING CO811734.0708039.51090.8968.1512.608
SOUTHERN ENERGY CO INC789522.7055142.850881.56553.7387.022
AMERICA WEST RESOURCES INC773643.04466519.095108.048330
ARCH COAL INC753266.4136954.126311.65411.6731.385
ZEIGLER COAL HOLDING CO808686.7695160.23360.34816.2010.197
PENNZENERGY CO352117.8139276.17211.10813.0850.34
UNITED MERIDIAN CORP794554.5897112.99882381.26623.9
TRITON ENERGY LTD612173.8495940.81730.4626.5860.319
XCL LTD115711.4669521.62767.43318.6816.61
LOUISIANA LAND & EXPLORATION338146.6624940.04482.41814.5010.439
AMERICAN EXPLORATION CO128113.9169912.33410.8719.7162.424
CHIEFTAIN INTL INC754783.4051563.32078.34417.4072.102
GOODRICH PETROLEUM CORP575092.5000421.70261.56917.041.188
NUEVO ENERGY CO762384.7797541.01430.55615.3574.62
WICHITA RIVER OIL381051.5575133.552718.8793.143

is there a simplier method? than listing your whole sample size in the command. I have a lot more data

Super User
Posts: 10,020

Re: RE: Mean, Median, Max, Min

Posted in reply to spraynardz90

Check it out,This can give you some GUI which is very convenient .

Super User
Posts: 11,343

Re: RE: Mean, Median, Max, Min

Posted in reply to spraynardz90

How do you get the YEAR out of this data? I don't see a likely field.

Valued Guide
Posts: 2,177

Re: RE: Mean, Median, Max, Min

Posted in reply to spraynardz90

spraynardz90

we would need just enough sample data to indicate data structure, because SAS will deal with the detail.

SAS can analyse your data, providing almost any statistic you can imagine

In Enterprise Guide, you need to point/load your data, then perform "tasks" upon it.

Probably the kind of tasks you need to use are among "Describe data"

hope this gets you started

good luck

peterC

Ask a Question
Discussion stats
  • 5 replies
  • 338 views
  • 0 likes
  • 4 in conversation