%put _automatic_;
%put this is some text to be put to the log;
%put This text was output: &systime &sysday &sysdate9 ;
%put The last dataset created was: &syslast;
/*without macro variables*/
proc freq data=orion.Customer;
table Country / nocum;
footnote1 "Created 11:47 Saturday, 11Feb2017";
footnote2 "By user dlm1 on system Linux";
run;
footnote;
/*with macro variables*/
proc freq data=orion.Customer;
table Country / nocum;
footnote1 'Created &systime &sysday, &sysdate9';
footnote2 'By user &sysuserid on system &sysscpl';
run;
footnote;
/*with macro variables*/
proc freq data=orion.Customer;
table Country / nocum;
footnote1 "Created &systime &sysday, &sysdate9";
footnote2 "By user &sysuserid on system &sysscpl";
run;
footnote;
%let mymacvar=Some text (often code goes here);
%put Mymacvar: &mymacvar;
%let txt="Some text in quotes";
%put The macro variable txt is: &txt;
/* without macro variables*/
proc freq data=orion.order_fact;
where year(order_date)=2007;
table order_type;
title "Order Types for 2007";
run;
proc means data=orion.order_fact;
where year(order_date)=2007;
class order_type;
var Total_Retail_Price;
title "Price Statistics for 2007";
run;
title;
/* with macro variables*/
%let year=2006;
proc freq data=orion.order_fact;
where year(order_date)=&year;
table order_type;
title "Order Types for &year";
run;
proc means data=orion.order_fact;
where year(order_date)=&year;
class order_type;
var Total_Retail_Price;
title "Price Statistics for &year";
run;
title;
data normals;
array x{10} x1-x10;
call streaminit(654321);
do rep=1 to 1000;
do n=1 to 10;
x{n}=rand("normal");
end;
mn=mean(of x{*});
output;
end;
run;
ods select histogram;
proc univariate data=normals;
var mn;
histogram mn/normal;
run;
%let obs=25;
%let sampsize=1000;
%let seed=54321;
data normals;
array x{*} x1-x&obs;
call streaminit(&seed);
do rep=1 to &sampsize;
do n=1 to &obs;
x{n}=rand("normal");
end;
mn=mean(of x{*});
output;
end;
run;
ods select histogram;
proc univariate data=normals;
var mn;
histogram mn/normal;
run;
%let numobs=30;
%let lambda=5;
%let numrep=100;
data expons;
call streaminit(1254731); /* set random number seed */
do rep=1 to &numrep;
do i = 1 to &numobs;
x = &lambda*rand("Exponential");
output;
end;
end;
run;
proc means data=expons ;
by rep;
var x;
output out=mnexp;
run;
data mnexp;
set mnexp;
where _stat_ ="MEAN";
rename x=mean;
run;
%let numobs=30;
%let lambda=5;
%let numrep=100;
options nonotes;
ods graphics off;
ods exclude all;
ods noresults;
data expons;
call streaminit(1254731); /* set random number seed */
do rep=1 to &numrep;
do i = 1 to &numobs;
x = &lambda*rand("Exponential");
output;
end;
end;
run;
proc means data=expons ;
by rep;
var x;
output out=mnexp;
run;
data mnexp;
set mnexp;
where _stat_ ="MEAN";
rename x=mean;
run;
%odson;
proc univariate data=mnexp;
var mean;
histogram mean /normal;
run;
%macro ODSOff(); /* Call prior to BY-group processing */
/* from the do loop, adapted*/
options nonotes;
ods graphics off;
ods exclude all;
ods noresults;
%mend;
%macro ODSOn(); /* Call after BY-group processing */
/* from the do loop, adapted*/
options notes;
ods graphics on;
ods exclude none;
ods results;
%mend;
filename filenm url "http://socrates.stat.fsu.edu/csv/orion/staff.csv";
proc import out=staff
datafile=filenm
dbms=csv replace;
getnames=yes;
datarow=2;
run;
%macro impdat(datanm);
filename filenm url "http://socrates.stat.fsu.edu/csv/orion/&datanm..csv";
proc import out=&datanm
datafile=filenm
dbms=csv replace;
getnames=yes;
datarow=2;
run;
%mend;
%impdat(customer)