*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s1d01 ***;
dm "output;clear;log;clear";
Libname Course2 "C:\_SasCourse2006\Course2\SAS_Data";
proc print data=Course2.growth; run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
data forecast;
drop NumEmps;
set Course2.growth;
Year=1;
NewTotal=NumEmps*(1+Increase);
output;
Year=2;
NewTotal=NewTotal*(1+Increase);
output;
Year=3;
NewTotal=NewTotal*(1+Increase);
output;
run;
proc print data=forecast noobs;
title 'Explicit output using the OUTPUT statement';
format NewTotal 6.;
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s2d01 ***;
dm "output;clear;log;clear";
Libname Course2 "C:\_SasCourse2006\Course2\SAS_Data";
proc print data=Course2.military; run;
proc print data=Course2.military noobs;
var Code Type;
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
data army navy airforce marines;
drop Type;
set Course2.military;
if Type eq 'Army' then
output army;
else if Type eq 'Naval' then
output navy;
else if Type eq 'Air Force' then
output airforce;
else if Type eq 'Marine' then
output marines;
run;
proc print data=marines noobs;
title 'Air Stations maintained by the US Marine Corps';
run;
* ... ;
proc print data=army noobs;
title 'Air Stations maintained by the US Army';
run;
proc print data=Navy noobs;
title 'Air Stations maintained by the US Navy';
run;
proc print data=airforce noobs;
title 'Air Stations maintained by the US Air Force';
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s3d01 ***;
dm "output;clear;log;clear";
Libname Course2 "C:\_SasCourse2006\Course2\SAS_Data";
proc contents data=Course2.military;
run;
data army navy airforce marines;
drop Type;
set Course2.military;
if Type eq 'Army' then
output army;
else if Type eq 'Naval' then
output navy;
else if Type eq 'Air Force' then
output airforce;
else if Type eq 'Marine' then
output marines;
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s3d02 ***;
dm "output;clear;log;clear";
Libname Course2 "C:\_SasCourse2006\Course2\SAS_Data";
data army(drop=City State Country Type)
navy(drop=Type)
airforce(drop=Code Type)
marines;
set Course2.military;
if Type eq 'Army' then
output army;
else if Type eq 'Naval' then
output navy;
else if Type eq 'Air Force' then
output airforce;
else if Type eq 'Marine' then
output marines;
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s3d03 ***;
dm "output;clear;log;clear";
Libname Course2 "C:\_SasCourse2006\Course2\SAS_Data";
data army(keep=Code Airport)
navy(keep=Code Airport City State Country)
airforce(keep=Airport City State Country)
marines;
set Course2.military;
if Type eq 'Army' then
output army;
else if Type eq 'Naval' then
output navy;
else if Type eq 'Air Force' then
output airforce;
else if Type eq 'Marine' then
output marines;
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s3d04 ***;
data army(keep=Code Airport);
set Course2.military(drop=City State Country);
if Type eq 'Army' then output;
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s3d05 ***;
data army;
set Course2.military(firstobs=11 obs=25);
if Type eq 'Army' then output;
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s4d01 ***;
dm "output;clear;log;clear";
Libname Course2 "C:\_SasCourse2006\Course2\SAS_Data";
ods csvall file='C:\_SasCourse2006\Course2\SAS_Data\export.dat';
footnote1 'data: Course2.maysales';
proc print noobs data=Course2.maysales;
format ListDate
SellDate date9.;
run;
ods csvall close;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s4d02 ***;
data _null_;
set Course2.maysales;
file 'export.dat'; * PC and Unix;
*file '.Course2.rawdata(export)'; * z/OS;
put Description
ListDate : date9.
SellDate : date9.
SellPrice;
run;
proc fslist fileref='export.dat'; * PC and Unix;
*proc fslist fileref='.Course2.rawdata(export)'; * z/OS;
run;
proc fslist fileref='C:\_SasCourse2006\Course2\SAS_Data\export.dat';
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s4d03 ***;
data _null_;
set Course2.maysales;
file 'export.dat'; * PC and Unix;
*file '.Course2.rawdata(export)'; * z/OS;
if _N_=1 then
put 'Description ListDate SellDate SellPrice';
put Description
ListDate : date9.
SellDate : date9.
SellPrice;
run;
proc fslist fileref='export.dat'; * PC and Unix;
*proc fslist fileref='.Course2.rawdata(export)'; * z/OS;
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s4d04 ***;
data _null_;
set Course2.maysales end=IsLast;
file 'export.dat'; * PC and Unix;
*file '.Course2.rawdata(export)'; * z/OS;
if _N_=1 then
put 'Description ListDate SellDate SellPrice';
put Description
ListDate : date9.
SellDate : date9.
SellPrice;
if IsLast=1 then
put 'Data: Course2.MAYSALES';
run;
proc fslist fileref='export.dat'; * PC and Unix;
*proc fslist fileref='.Course2.rawdata(export)'; * z/OS;
run;
*---+----1----+----2----+----3----+----4----+----5----+----6----+---;
*** c02s4d05 ***;
data _null_;
set Course2.maysales end=IsLast;
file 'export.dat' dlm=','; * PC and Unix;
*file '.Course2.rawdata(export)'; * z/OS;
if _N_=1 then
put 'Description,ListDate,SellDate,SellPrice';
put Description
ListDate : date9.
SellDate : date9.
SellPrice;
if IsLast=1 then
put 'Data: Course2.MAYSALES';
run;
proc fslist fileref='export.dat'; * PC and Unix;
*proc fslist fileref='.Course2.rawdata(export)'; * z/OS;
run;