BookmarkSubscribeRSS Feed

[PROC HTTP] Dropbox에 저장되어 있는 SAS 데이터 세트 사용하기(THE SAS Dummy, Chris Hemedinger)

Started ‎06-14-2020 by
Modified ‎06-14-2020 by
Views 147

* Dropbox에 저장되어 있는 SAS 데이터 세트 사용하기;

 

http://cafe.daum.net/statsas/3F8j/308 ;

 

* Using SAS to access data stored on Dropbox;

* GET 방식;

* 출처 : http://blogs.sas.com/content/sasdummy/2012/12/18/using-sas-to-access-data-stored-on-dropbox/;

* 저자 : THE SAS Dummy, Chris Hemedinger;

 

filename _inbox "%sysfunc(getoption(work))/streaming.sas7bdat";

 

proc http method="get" 

 url="https://dl.dropbox.com/s/pgo6ryv8tfjodiv/streaming.sas7bdat" 

 out=_inbox

 /* proxyhost="http://yourproxy.company.com" */

;

run;

 

filename _inbox clear;

 

proc contents data=work.streaming;

run;

 

 

* CPORT 프로시져로 생성된 이송 파일(Transport file)에 접근하기(CARS와 CLASS 데이터 세트);

 

filename _inbox TEMP;

 

proc http method="get" 

 url="https://dl.dropbox.com/s/5uehelsok9oslgv/sample.cpo" 

 out=_inbox

  /* proxyhost="http://yourproxy.company.com" */

;

run;

 

proc cimport file=_inbox lib=work;

run;

filename _inbox clear;

 

 

* %include 구문을 사용하여서 클라우드(cloud) 에 존재하는 SAS 프로그램 사용하기;

* ifsxmas.sas 의 내용은 아래 하단 참조;

 

filename _inbox "%sysfunc(getoption(work))/ifsxmas.sas";

proc http method="get" 

 url="https://dl.dropbox.com/s/g1hat0woohud9yc/IFSChristmasTree.sas" 

 out=_inbox

  /* proxyhost="http://yourproxy.company.com" */

;

run;

%include _inbox;

filename _inbox clear;

 

 

* 깃헙(GitHub) 에 존재하는 SAS 데이터 세트 접근하기;

 

filename _inbox "%sysfunc(getoption(work))/streaming.sas7bdat";

 

proc http method="get" 

 url="https://github.com/cjdinger/proc_http_example/raw/master/data/streaming.sas7bdat" 

 out=_inbox

 /* proxyhost="http://yourproxy.company.com" */

;

run;

 

filename _inbox clear;

 

proc contents data=work.streaming;

run;

 

 

 

* 구글 드라이브(Google Drive) 에 존재하는 SAS 데이터 세트 접근하기;

filename _inbox "%sysfunc(getoption(work))/streaming.sas7bdat";

 

proc http method="get" 

 url="https://docs.google.com/uc?export=download%str(&)id=0BwSh7LOTCPQ5MmlJZFdOOFJhOHc" 

 out=_inbox 

 /* proxyhost="http://yourproxy.company.com" */

;

run;

 

filename _inbox clear;

 

proc contents data=work.streaming;

run;

 

 

 

 

* https://dl.dropbox.com/s/g1hat0woohud9yc/IFSChristmasTree.sas;

 

 

proc iml;

/* Using SAS to construct a Christmas Tree from an iterated function system,

   and adding ornaments and a star.

   Rick Wicklin 12/14/2012

   To construct an iterated function system in SAS, see

   http://blogs.sas.com/content/iml/2012/12/12/iterated-function-systems-and-barnsleys-fern-in-sas/

*/

/* 1. Each row is a 2x2 linear transforamtion */

/* Christmas tree */

L = {0.03    0   0    0.1,

     0.85 0.00  0.00 0.85,

     0.8 0.00  0.00 0.8,

     0.2 -0.08  0.15 0.22,

    -0.2  0.08  0.15 0.22,

 0.25 -0.1  0.12 0.25,

    -0.2  0.1  0.12 0.2};

/* ... and each row is a translation vector */

B = {0 0,

     0 1.5,

     0 1.5,

     0 0.85,

     0 0.85,

     0 0.3,

     0 0.4

 };

prob = { 0.02 0.6 0.1 0.07 0.07 0.07 0.07};

/* For convenience, transpose the L and B matrices */

L = L`; B = B`;

 

/* 3. iterate the discrete stochastic map */

N = 1e5;          /* number of iterations */

x = j(2,N); k = j(N,1);

x[,1] = {0, 2};   /* initial point */

call randseed(1);

call randgen(k, "Table", prob);

 

do i = 2 to N;

   x[,i] = shape(L[,k[i]], 2)*x[,i-1] + B[,k[i]];

end;

 

/* 4. plot the iteration history */

y = x`;

create IFS from y[c={"x" "y"}]; append from y; close IFS;

 

/* just for fun, create ornaments and colors */

idx = ceil(N*ranuni(j(500,1)));

x1 = x[1,idx]`;

jdx = loc(abs(x1)>0.04);

idx = idx[jdx];

x1 = x[1,idx]`;

y1 = x[2,idx]` - 0.1;

group = ceil(5*ranuni(j(nrow(idx),1)));

create Ornaments var {x1 y1 group}; append; close Ornaments;

quit;

 

/* basic IFS Christmas Tree */

ods graphics / width=200px height=400px;

proc sgplot data=IFS;

title "SAS Christmas Tree (from The DO Loop blog)";

scatter x=x y=y / markerattrs=(size=1 color=ForestGreen);

yaxis display=none;

xaxis display=none;

run;

 

/* Add ornaments and star */

data Star;

x2=0; y2=10; output;

run;

 

data All;

merge IFS Ornaments Star;

if group=. then group=1;

run;

 

data Attrs;

length Value MarkerColor $20;

ID = "Ornaments"; 

Value = 1; MarkerColor = "Red    "; output;

Value = 2; MarkerColor = "Blue   "; output;

Value = 3; MarkerColor = "Purple "; output;

Value = 4; MarkerColor = "Gold   "; output;

Value = 5; MarkerColor = "Chartreuse"; output;

run;

 

*ods graphics / width=400px height=800px;

proc sgplot data=All noautolegend dattrmap=Attrs;

title "SAS Christmas Tree (from The DO Loop blog)";

scatter x=x y=y / markerattrs=(size=1 color=ForestGreen);

scatter x=x1 y=y1 / transparency=0.33 attrid=Ornaments

        markerattrs=(size=8 symbol=CircleFilled) group=group;

scatter x=x2 y=y2 / markerattrs=(color=Gold size=15 symbol=StarFilled);

yaxis display=none;

xaxis display=none;

run;

Version history
Last update:
‎06-14-2020 10:42 PM
Updated by:
Contributors

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Article Labels
Article Tags