data test; do i=1 to 10; x=rannor(20394); output; end; run;
proc print data=test(firstobs=2 obs=5); run;
proc print data=test; where( 2 <= _n_ <= 5); run;
data _null_; set test; file "c:\foo.txt"; put i 2. x 12.5; run;
libname perm "e:\sasdata"; data perm.foobar; set test; run;
data test1; set perm.foobar; run;
proc means data=test(firstobs=3 obs=4); run;
data math; infile 'R:\foo.dat' obs=10000 truncover lrecl=530;
data test; do i=1 to 100; x=rannor(20394); output; end; run; title "Default"; proc chart data=test; hbar x; run; title "Ascending"; proc chart data=test; hbar x / midpoints=-3 to 3 by .5; run; title "Descending"; proc chart data=test; hbar x / midpoints=3 to -3 by -.5; run; title;
data math; infile 'R:\foo.dat' firstobs=4;
data math; infile 'R:\foo.dat' lrecl=200;
data mon2002; infile 'd:\home\monitor\assign2002\ver2\mon_all8d.csv' dlm=',' firstobs=2 truncover;
data daigaku05;
length unin $ 20.;
infile 'd:\home\monitor\assign2002\ver2\mon_all8d.csv' dlm=','
firstobs=2
truncover;
input id $ unin $ depn $ ;
とすれば良い。
これを以下のように指定すると、カンマを超えて読み込んでしまう(悪い例)。
data daigaku05;
infile 'd:\home\monitor\assign2002\ver2\mon_all8d.csv' dlm=','
firstobs=2
truncover;
input id $ unin $ 20. depn $ ;
data Sogo; infile 'C:\foo\総合試験実施大学一覧l.csv' firstobs=6 truncover lrecl=240 dlm=',' dsd missover ; input No $ Univ : $30. SName : $40. Faculty : $50. Dept : $50. Center1 : $8. Center2 : $8. Sel1 : $8. Sel2 : $8. Book1 : $10. Book2 : $10. Vol0 VolS VolT ZenKou $ ScoreS ScoreT KoKouSi ;
data mon2002; infile 'd:\home\monitor\assign2002\ver2\mon_all8d.txt' dlm='09'x firstobs=2 truncover;
input id $ 7-11 Cage $ 14-15 Csex $ 22 Sgr1 33-35 Sgr2 41-43 Sgr3 47-49 Stotal 53-55 ;
[参考] : テキスト・ファイルの行末コードを変更する
/* global01.sas */ /* File Name = global01.sas 10/21/04 */ /* */ /* ケースをわたって値を保持する変数 */ /* [例] ある変量の総和を求めたい */ options nocenter linesize=78 pagesize=9999; DATA sample; INPUT Sgr1 Sgr2 Sgr3; CARDS; 30 17 24 34 17 33 53 35 56 61 30 50 57 21 55 62 34 55 56 23 49 57 23 55 57 21 42 56 26 49 ; run; proc print data=sample; run; proc means data=sample maxdec=2 n mean sum; var Sgr1 Sgr2 Sgr3; run; title "*** global variable ***"; data tmp1; RETAIN sum1-sum3 0.0; set sample; sum1=sum1+Sgr1; sum2=sum2+Sgr2; sum3=sum3+Sgr3; run; proc print data=tmp1; var sum1-sum3; run;
sas.exe source.sas -print listfile.lst -log logfile.log
proc freq data=gakusei; tables OYear*OTerm; tables ID*SCatG / nopercent norow nocol; tables ID*Bunri / nopercent norow nocol; run;
proc means data=gakusei SUM MEAN MIN MAX; var Unit; by SCatS; class ID; output out=omean1 N=n1 SUM=su1 MEAN=me1 MIN=mi1 MAX=ma1; run;
ods listing gpath='/folders/myfolders/foo/SAS_ODS01'; proc boxplot data=TK2; plot ScoreA*SubA / BOXSTYLE=SCHEMATIC; run; proc sgscatter data=TK2; title "Scatterplot Matrix for TK2"; matrix ScoreA ScoreB ScoreC ScoreT; run; title "";