SAS



data xxx;

input   int $   trt  $ no;

datalines;

 mild  R 13

 mode R 0

 sev R 2 

  mild T 13

 mode T 3

 sev T 0

 ;

 run;


 proc freq data = xxx ;

 weight no ;

 tables  trt *int /chisq ;

 run ;



data respire; input treat $ outcome $ count ; 

cards; 

test f 40 

test u 20 

placebo f 16 

placebo u 48; 


proc freq; 

weight count; 

tables treat*outcome/measures chisq; 

run;


sas 카이제곱검정에 대한 이미지 검색결과



 참고파일

Sas_web.pdf



#SAS Code for Confidence Intervals for a Proportion


data veg; 

  input response $ count; datalines; 

       no 25 yes 0 ; 

run ;


proc freq data=veg; 

  weight count; tables response / binomial(ac wilson exact jeffreys) alpha=.05; 

run;


#SAS Code for Chi-Squared, Measures of Association, and Residuals for Data on Education

data table; 

  input degree belief $ count @@; 

  datalines; 1 1 9 1 2 8 1 3 27 1 4 8 1 5 47 1 6 236 2 1 23 2 2 39 2 3 88 2 4 49 2 5 179 2 6 706 3 1 28 3 2 48 3 3 89 3 4 19 3 5 104 3 6 293 ; 

run ;

proc freq order=data; 

 weight count; tables degree*belief / chisq expected measures cmh1; 

run ;


proc genmod order=data; class degree belief; model count = degree belief / dist=poi link=log residuals; 


run;

 

#: SAS Code for Confidence Intervals for 2×2 Table

data example;

 input group $ outcome $ count @@; 

datalines; placebo yes 2 placebo no 18 active yes 7 active no 13 ; 


proc freq order=data; weight count; 

   tables group*outcome / riskdiff(CL=(WALD MN)) measures; 

       * MN = Miettinen and Nurminen inverted score test; 

run; 


#SAS Code for Fisher’s Exact Test and Confidence Intervals for Odds Ratio

data fisher;

 input poured guess count @@; 

datalines; 1 1 3 1 2 1 2 1 1 2 2 3 ; 


proc freq; weight count; 

tables poured*guess / measures riskdiff; exact fisher or / alpha=.05; 


proc logistic descending; 

freq count; 

model guess = poured / clodds=pl; 

run;


# SAS Code for “Exact” Confidence Intervals for 2×2 Table

data example; 

input group $ outcome $ count @@; 

datalines; placebo yes 2 placebo no 18 active yes 7 active no 13 ; 


proc freq order=data; weight count; 

tables group*outcome ; 

exact or riskdiff(CL=(MN)) ; 

run; 


proc freq order=data; weight count; 

tables group*outcome ; 

exact riskdiff(method=score); 

* exact unconditional inverting two one-sided score tests; 

run; 


#SAS Code for Binary GLMs for Snoring Data

data glm; 

input snoring disease total @@; 

datalines; 

0 24 1379 2 35 638 4 21 213 5 30 254 ; 

proc genmod; model disease/total = snoring / dist=bin link=identity; proc genmod; model disease/total = snoring / dist=bin link=logit LRCI; proc genmod; model disease/total = snoring / dist=bin link=probit; run;

'통계 clinical trial > SAS' 카테고리의 다른 글

Data문 DATA set 분리  (0) 2018.11.21
PROC SORT를 이용한 중복자료 삭제  (0) 2018.11.16
proc GLM for BE  (0) 2018.11.08
ODS 특수기능  (0) 2018.11.07
proc report output 출력 순서..  (0) 2018.11.06
블로그 이미지

고향이안드로메다

,

proc GLM for BE

2018. 11. 8. 23:55

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.


Output 출력물 내용확인하기

  ods trace on;  ---> ods trace off;



ANOVA 등 결과물 출력막기

   ods exclude all ;  ---> ods exclude close ;


코드를 다시 실행할 때 모든 결과물 정리하기  새로운 마음으로//

   dm 'log; clear; odsresults ; clear; output; clear' ;

'통계 clinical trial > SAS' 카테고리의 다른 글

proc FREQ (in SAS and Excel)  (0) 2018.11.09
proc GLM for BE  (0) 2018.11.08
proc report output 출력 순서..  (0) 2018.11.06
proc report에 format 처러하기 및 통계처리  (0) 2018.11.04
Proc Transpose  (0) 2018.11.04
블로그 이미지

고향이안드로메다

,

Ref



trt : R, T

foldserseq = 1, 2, 3, 4...

instantname = A C B D..




column trt folserseq instantname  ;


foldserseq 순서대로


define trt /group  ;

define folserseq / group  order = internal noprint ;

define instantname /group "Visit" ;


Instantname 순서대로


define trt /group  ;

define folserseq / group  noprint ;

define instantname /group "Visit" ;



'통계 clinical trial > SAS' 카테고리의 다른 글

proc GLM for BE  (0) 2018.11.08
ODS 특수기능  (0) 2018.11.07
proc report에 format 처러하기 및 통계처리  (0) 2018.11.04
Proc Transpose  (0) 2018.11.04
엑셀 파일 만들기 (ODS EXCEL)  (0) 2018.11.02
블로그 이미지

고향이안드로메다

,

참조1

참조2  Format Challenges with PROC REPORT


define distance /analysis format=comma12. "(feet)";  


proc format ;

 value $aaa

   a  ="A"

   b ="B"

   c ="C"  를 참조할 때 format = $aaa.   (점을 꼭 찍어야함)


value bbb



columns (TRT   folderseq1  InstanceName1 &analyte=a1  &analyte=a2 &analyte=a3 &analyte=a4 &analyte=a5 &analyte=a6) ('Change from baseline' change pct_chg);


define trt /group format = $trtf. "TRT"; 

 define folderseq1 /group order = internal  noprint ;

define InstanceName1  /group  center  "Visit and Time";



define a1/analysis n format=5.0 center "N" ;  

define a2/analysis mean format=5.2 center  "Mean";  

define a3/analysis std format=5.2 center  "SD";  

define a4/analysis min format=5.2 center  "Min";  

define a5/analysis median format=5.2 center  "Median";

define a6/analysis max format=5.2 center  "Max";

define change/analysis mean format=5.2 center  "Mean change";

define pct_chg/analysis mean format=5.2 center  "Mean change(%)";

'통계 clinical trial > SAS' 카테고리의 다른 글

ODS 특수기능  (0) 2018.11.07
proc report output 출력 순서..  (0) 2018.11.06
Proc Transpose  (0) 2018.11.04
엑셀 파일 만들기 (ODS EXCEL)  (0) 2018.11.02
SAS에서 excel 파일 불러오기 (PROC IMPORT)  (0) 2018.11.02
블로그 이미지

고향이안드로메다

,

참조 homepage:

 

proc sort data = xxx ; by group ; run ;

Proc transpose data = xxx out = yyy ;

by group ;   *** y축 나열 **** ;

var code ;

run ;




블로그 이미지

고향이안드로메다

,
ods excel file="c:\projects\output\example.xlsx" 
 /* will apply an appearance style */
 style=pearl
 options(
                        /* for multiple procs/sheet */
  sheet_interval="none" 
                     /* name the sheet tab */
  sheet_name="CARS summary"
 );
 
/* add some formatted text */
ods escapechar='~';
ods text="~S={font_size=14pt font_weight=bold}~Cars Summary and Histogram";
 
/* tabular output */
proc means data=sashelp.cars;
var msrp invoice;
run;
 
/* and a graph */
ods graphics / height=400 width=800 noborder;
proc sgplot data=sashelp.cars;
histogram msrp;
run;
 
ods excel close;


'통계 clinical trial > SAS' 카테고리의 다른 글

proc report에 format 처러하기 및 통계처리  (0) 2018.11.04
Proc Transpose  (0) 2018.11.04
SAS에서 excel 파일 불러오기 (PROC IMPORT)  (0) 2018.11.02
P-value 집어넣기  (0) 2018.11.01
반올림 버림  (0) 2018.11.01
블로그 이미지

고향이안드로메다

,

1) proc import


PROC IMPORT OUT=raw.data1           DATAFILE="C:\Users\UOS\Desktop\excel\101_DT_1K52B01_20140707170219_2.xlsx"
            DBMS=  XLSX   REPLACE;
            SHEET="sheet1";

           range="Sheet1$E7:K17" ;


statements for importing from delimited files

DATAROW=n;         *** 어느 열부터 읽기시작 ********
DELIMITER=char | 'nn'x;
GETNAMES=YES | NO; ** variable name 유무 default는 yes
GUESSINGROWS=n | MAX;


*변수명 바꾸기*/
%macro varname_change(data);
data &data;
 set &data;

 rename VAR1 = rigion
   VAR2 = industry
   VAR3 = biz
   VAR4 = num_biz
   VAR5 = num_emp;

 label VAR1 = '행정구역별'
   VAR2 = '산업별'
   VAR3 = '사업체구분별'
   VAR4 = '사업체수'
   VAR5 = '종사자수';
run;
%mend;

%varname_change(raw.data1);
%varname_change(raw.data2);
%varname_change(raw.data3);
%varname_change(raw.data4);
%varname_change(raw.data5);

 

/*필요없는 변수 제거*/
%macro var_drop(data);
data &data;
 set &data;
 drop biz;
run;
%mend;
%var_drop(raw.data1);
%var_drop(raw.data2);
%var_drop(raw.data3);
%var_drop(raw.data4);
%var_drop(raw.data5);

 

Available Statements for Importing and Exporting Excel Files Using DBMS=XLS and DBMS=XLSX     

DBMS= Identifier

Option

Valid Value

Default Value

PROC

PROC

    

IMPORT

EXPORT

XLS

ENDCOL

Last column for data

Last column that contains data

Yes

No

 

ENDNAMEROW

Last row for variable names

Same as NAMEROW

Yes

No

 

ENDROW

Last row for data

Last row that contains data

Yes

No

 

GETNAMES

Yes | No

Yes

Yes

No

 

NAMEROW

First row for variable names

First row that contains variable names

Yes

No

 

NEWFILE

Yes | No

No

No

Yes

 

PUTNAMES

Yes | No

Yes

No

Yes

 

RANGE

name | sheet$ul:lr

First row

Yes

No

 

SHEET

Sheet name

First sheet

Yes

Yes

 

STARTCOL

First column for data

Last column that contains data

Yes

No

 

STARTROW

First row for data

First row that contains data

Yes

No

XLSX

GETNAMES

Yes | No

Yes

Yes

No

 

RANGE

name | sheet$ul:lr

First row

Yes

No

 

SHEET

Sheet name

First sheet

Yes

Yes

2) SAS LIBNAME Statement for EXCEL and ACCESS Engine 

     (sas 9.4부터 가능)

 LIBNAME <libref> engine-name <'physical-path and filename.ext'> 

<SAS/ACCESS engine-connection-options> 
<SAS/ACCESS LIBNAME-options>;


/* because Excel field names often have spaces */
options validvarname=any;
 
libname xl XLSX '/folders/myfolders/sas_tech_talks_15.xlsx';
 
/* discover member (DATA) names */
proc datasets lib=xl; quit;
 
libname xl CLEAR;


만약 excel에서 특정data sheet (sheet1)를 불러오고자 할떄는

data xxx ; set xl.sheet1 ;

run ;


'통계 clinical trial > SAS' 카테고리의 다른 글

Proc Transpose  (0) 2018.11.04
엑셀 파일 만들기 (ODS EXCEL)  (0) 2018.11.02
P-value 집어넣기  (0) 2018.11.01
반올림 버림  (0) 2018.11.01
datetime 변수에서 날짜와 시간을 분리  (0) 2018.11.01
블로그 이미지

고향이안드로메다

,