• No results found

* --- Alle labels kan nu bestemmes i PROC PRINT ;

N/A
N/A
Protected

Academic year: 2021

Share "* --- Alle labels kan nu bestemmes i PROC PRINT ;"

Copied!
11
0
0

Loading.... (view fulltext now)

Full text

(1)

Foredrag på SAS Forum, 18. september 2013

Nyheder i SAS 9.4 for SAS programmører, Georg Morsing

Program 1

* --- Alle labels kan nu bestemmes i PROC PRINT ---; proc print data=sashelp.cars

label

grandtotal_label='Total for begge biler'

sumlabel='Subtotal'

noobs;

where make in ('Audi','BMW') and invoice > 40000; by make ;

var model invoice; sum Invoice;

label invoice='Pris'

make ='Producent';

run;

Program 2

/* --- Ny option CUROBS til SET og MODIFY statements --- */ data piger;

set sashelp.class curobs=obs;

where sex='F'; obs_num=obs;

(2)

Program 3

/* --- Ændring i SCAN funktion. Ny variabel er ikke Længere 200 lang, men længden af det første

argument --- */ data; Navn='Georg Morsing'; e_navn=scan(navn,2); run;

Program 4

/* --- Ny options til PUTC og PUTN funktioner --- */ proc format; value agefmt 10-13='10-13 år' 14-16='14-16 år'; run; data test; set sashelp.class;

length alder alder_c alder_r $ 20; alder = putn(age,'agefmt.');

alder_c = putn(age,'agefmt.-c',20); alder_r = putn(age,'agefmt.-r',20); if _n_=1 then

do;

put '*' alder $char20. '*'; put '*' alder_c $char20. '*'; put '*' alder_r $char20. '*'; end;

(3)

Program 5

/* --- Ny DOSUBL funktion til at udføre SAS kode midt i et data step --- */

data test; Navn='Georg';

rc=dosubl('proc sql; select count(age) into :antal from sashelp.class;run;'); hvor_mange= symgetn("antal");

run;

data test;

set sashelp.class;

rc=dosubl('proc sql noprint; select avg(weight) into :w from sashelp.class;run;'); avg_weight= symgetn("w"); run; data test; set sashelp.class; if sex='F' then

rc=dosubl('proc sql noprint; select avg(weight) into :w from sashelp.class where sex="F";run;');

if sex='M' then

rc=dosubl('proc sql noprint; select avg(weight) into :w from sashelp.class where sex="M";run;');

avg_weight= symgetn("w");

run;

Program 6

libname orion 'C:\Georg\SAS Forum DK 2013\SAS 9_4\Data';

data find_priser; input product_id; datalines; 210100100010 210100100011 ; run;

(4)

/* --- Multiple key værdier i et HASH objekt SAS 9.3 --- */

data prices;

if _N_ = 1 then do;

if 0 then set orion.price_list;

declare hash price(dataset: "orion.price_list", multidata: "y");

price.definekey("product_id");

price.definedata("start_date", "end_date", "unit_sales_price"); price.definedone(); end; set work.find_priser; if price.find()=0 then do; output; price.has_next(result: next); do while(next = 1); price.find_next(); output; price.has_next(result: next); end; end;

keep product_id start_date end_date unit_sales_price;

run;

/* --- Multiple key værdier i et HASH objekt SAS 9.4 --- */

data prices;

if _N_ = 1 then do;

if 0 then set orion.price_list;

declare hash price(dataset: "orion.price_list", multidata: "y");

price.definekey("product_id");

price.definedata("start_date", "end_date", "unit_sales_price"); price.definedone(); end; set work.find_priser; if price.find()=0 then do; price.reset_dup(); do while(price.do_over() eq 0); output; end; end;

keep product_id start_date end_date unit_sales_price;

(5)

Program 7

/* --- VBUFSIZE option er buffer størrelse til data step views --- */

/* --- Sæt VBUFSIZE til samme værdi

som bufsize på input tabel --- */

proc options option=vbufsize ;

run;

data test(bufsize=1M); length text $ 400;

retain text 'Meget lang text'; do I=1 to 10000000;

x= round(ranuni(0));

output; end;

run;

proc contents data=test;

run;

data test2 / view=test2; set test;

y=x*.5;

run;

Proc means data=test2;

var x y;

run;

options vbufsize=1M;

Proc means data=test2;

var x y;

(6)

Program 8

/* --- Bevar alt i din SAS session til senere --- */ options presenv;

%let navn=Georg Morsing;

data piger drenge;

set sashelp.class;

if sex='F' then output piger; else if sex='M' then output drenge;

run;

libname sasdata 'c:\temp\data';

filename programs 'c:\temp\programs.sas';

proc presenv save permdir=sasdata sascode=programs;

run;

/* --- Hent den SAS session du sluttede med sidst --- */ %include 'c:\temp\programs.sas';

(7)

Program 9

/* --- Ny system options, besked om manglende initialization ---*/

options varinitchk=note;

data test;

set sashelp.class;

length gruppe $ 10;

run;

options varinitchk=nonote;

data test;

set sashelp.class;

length gruppe $ 10;

run;

options varinitchk=warning;

data test;

set sashelp.class;

length gruppe $ 10;

run;

options varinitchk=error;

data test;

set sashelp.class;

if weihgt > 100 then gruppe='Større end 100';

(8)

Program 10

title;footnote;

/* --- Placer flere typer af output på samme side --- */ /* --- Eksempel 2 --- */ ods layout gridded columns=2;

ods region;

proc print data=sashelp.class; run; ods region;

proc print data=sashelp.class; run;

ods layout end;

/* --- Eksempel 2 --- */ ods layout gridded rows=3 row_heights=(1in 2in 3in); ods region;

proc print data=sashelp.class(obs=1); run; ods region;

proc means data=sashelp.class n mean; run; ods region;

proc print data=sashelp.class(obs=3); run;

(9)

Program 12

options nonumber nodate;

/* -- Send rapporter og grafer direkte til Powerpoint -- */

ods powerpoint file='c:\temp\georg.ppt' style=htmlblue;

proc sgplot data=sashelp.class;

bubble x=Age y=Height size=Weight / group=Sex

datalabel=name transparency=.3 ; yaxis grid;

run;

proc sgpanel data=sashelp.class; panelby sex;

bubble x=Age y=Height size=Weight / datalabel=name transparency=.3 ; rowaxis grid;

run;

ods powerpoint close;

Program 13

/* --- Danne powerpoint slides med PROC ODSTEXT --- */

title;

ods powerpoint file='c:\temp\georg.ppt' layout=titleslide;

proc odstext;

p 'Denne tekst er dannet med den nye PROC ODSTEXT' / style=presentationtitle; p 'SAS Forum 2013, Georg Morsing' / style=presentationtitle;

run;

ods powerpoint layout=_null_;

proc sgplot data=sashelp.class;

bubble x=Age y=Height size=Weight / group=Sex datalabel=name transparency=.3 ;

yaxis grid;

run;

(10)

Program 14

/* --- Send output til mobile enheder --- */ ods graphics;

ods epub file='c:\temp\bubleplot.epub'

title='Analyse'

options(creator='Georg');

proc freq data=sashelp.class;

tables age*sex / plots=freqplot nocol norow nopercent;

run;

ods epub close;

Program 15

/* --- DATA Step 2, udnyt flere CPU'er --- */

data work.jmaster;

do j = 1 to 10000000; output;

end;

run;

/* Definer koden der skal køres */ proc ds2;

thread r /overwrite=yes; dcl double count;

dcl double k; dcl double x; method run();

set {select * from work.jmaster}; count+1;

do k=1 to 100;

x=k/count + k/count + k/count;

(11)

end; method term(); OUTPUT; end; endthread; run; quit; /* 1 thread */ proc ds2;

data j1(overwrite=yes);

dcl thread r r_instance;

dcl double count; dcl double total; method run();

set from r_instance threads=1; total+count; end; enddata; run; quit; /* 8 threads */ proc ds2;

data j8(overwrite=yes);

dcl thread r r_instance;

dcl double count;

dcl double total; method run();

set from r_instance threads=8; total+count; end; enddata; run; quit; title;footnote;

proc print data=j8(obs=5);

var j count total;

References

Related documents

This indicates a gradual process of the soil contamination by heavy metals from the landfill, following the general topography of the land surface, the direction of groundwater

Digital governance is seen being adopted by some SUCs as an innovative tool in learning, promoting citizen participation and advocating peace.. Keywords: digital

The fact that in 1977 Thailand had already reached the export expansion stage in cotton and man-made yarn and fabric production, while the Philippines,supposedlythe pioneer, was

Using water assists flushing of scale and keeping cleaning tool more affective Using water removes heat from critical areas increasing life. Using pneumatically powered vertical

The African Growth and Opportunity Act (AGOA) is a unilateral trade policy concession governing United States – Sub-Saharan Africa (SSA) trade and investment

In this regard, there are already several signs that underline the seriousness of policy makers in putting the Paris agreement into practice, such as the ongoing elaboration

We report on human papillomavirus vaccination in adolescent boys using the Immunization Information System since the October 2011 Advisory Committee on Immunization

The bottled mineral water collected from shops randomly were analyzed for all parameters address on manufacturer's labeling and the results were compared with the