Data homegarden;
INFILE cards;
INPUT Name $ 1-7 Tomato Zucchini Peas Grapes;
Zone = 14;
Type = 'home';
Zucchini = Zucchini*10;
Total = Tomato+Zucchini + peas + Grapes;
PerTom = (Tomato/Total)*100;
cards;
Gregor 10 2 40 0 14
Molly 15 5 10 1000
Luther 50 10 15 50
Susan 20 0 . 20
;
Proc print Data=homegarden;
Title 'home gardening survey';
run;
Data pumpkin;
inFile cards;
input name $1-16 age type $1. +1 date MMDDYY10. s1 s2 s3 s4 s5;
type = upcase(type);
avgscore = mean(s1,s2,s3,s4,s5);
DayEntered = Day(date);
cards;
Alicia Grossman 13 c 10-28-2003 7.8 6.5 7.2 8.0 7.9
Matthew Lee 9 D 10-30-2003 6.5 5.9 6.8 6.0 8.1
Elizabeth Garcia 10 C 10-29-2003 8.9 7.9 8.5 9.0 8.8
;
proc print data=pumpkin;
run;
data cars;
infile cards;
input name $ year make $ seats color $;
if year < 1975 then status = 'classic';
if name = 'Corvette' or name = 'Camaro' then make = 'Chevy';
if name = 'Miata' then Do;
make = 'mazda';
seats = 2;
end;
cards;
Corvette 1955 . 2 black
XJ6 1995 Jaguar 2 teal
Mustang 1966 Ford 4 red
Miata 2002 . . silver
CRX 2001 Honda 2 black
Camaro 2000 . 4 red
;
proc print data=cars;
run;
data home;
infile cards;
input name $1-7 works $9-33 cost;
if cost = '.' then costgroup = 'missing';
else if cost > 50000 then costgroup = 'high';
else if cost < 10000 then costgroup = 'low';
else costgroup = 'medium';
cards;
Bob Kitchen cabinet face-lift 1253.00
Shirley bathroom addition 11350.70
Silvia paint exterior .
Al backyard gazebo 3098.63
Norm paint interior 647.77
Kathy second floor additon 75362.93
;
proc print data=home;
run;
data Shakespeare;
infile cards;
input name $ 1-25 year type $;
if type = 'comedy';
cards;
A Midsummer Night's Dream 1595 comedy
Comedy of Errors 1590 comedy
Hamlet 1600 tragedy
Macbeth 1606 tragedy
Richard III 1594 history
Romeo and Julirt 1596 tragedy
Taming of the Shrew 1593 comedy
Tempest 1611 romance
;
proc print data=shakespeare;
run;
data date;
infile cards;
input name $1-11 +3 birthday date9. +1 IssueDate MMDDYY10.;
ExpireDate = IssueDate + (365.25*3);
ExpireQuarter = QTR(ExpireDate);
if IssueDate > '01JAN2003'D then NewCard = 'yes';
cards;
A. Jones 1jan60 9-15-03
M. Rincon 05oCT1949 02-29-2000
Z. Grandage 18mar1988 10-10-2002
K. Kaminaka 29may2001 01-24-2003
;
proc print data=date;
Format IssueDate MMDDYY10.;
Format birthday YYMMDD10.;
Format ExpireDate weekdate17.;
run;
data games;
infile cards;
input day $ players $20. hits runs;
retain var 0;
var = sum(var, runs);
retain maxrun 0;
maxrun = max(maxrun, runs);
cards;
6-19 Columbia Peaches 8 3
6-20 Columbia Peaches 10 5
6-23 Plains Peanuts 3 4
6-24 Plains Peanuts 7 2
6-25 Plains Peanuts 12 8
6-30 Gilroy Garlics 4 4
7-1 Gilroy Garlics 9 4
7-4 Sacramento Tomatoes 15 9
7-4 Sacramento Tomatoes 10 10
7-5 Sacramento Tomatoes 2 3
;
proc print data=games;
run;
网友评论