66 slides misug forpdf.ppt [read-only]...2. ods tagsets.excelxp 0 you want to present p‐values for...

20

Upload: others

Post on 27-Mar-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead
Page 2: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

Overview1. ODSTRACE2. ODSTAGSETS.EXCELXP3. PROCTRANSPOSEwithID4. CALLSYMPUT5. SGANNO6. DICTIONARY.COLUMNS7. PROCSQLSELECTINTO:

Page 3: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

1.ODSTRACE0 TheODSTRACEcommand,usedwithanySAS®PROC,createsalistintheLogwindowofalldatatablestheprocedureisabletogenerate.

ODS TRACE ON; PROC REG DATA = SASHELP.CLASS;

MODEL WEIGHT = AGE; RUN; ODS TRACE OFF;

Output Added: ‐‐‐‐‐‐‐‐‐‐‐‐‐Name: ANOVA Label: Analysis of Variance Template: Stat.REG.ANOVA Path: Reg.MODEL1.Fit.Weight.ANOVA 

Output Added: ‐‐‐‐‐‐‐‐‐‐‐‐‐Name: ParameterEstimates Label: Parameter Estimates Template: Stat.REG.ParameterEstimates Path: Reg.MODEL1.Fit.Weight.ParameterEstimates

Page 4: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

2.ODSTAGSETS.EXCELXP0 Youwanttopresentp‐valuesforthecoefficients

fromasimplelinearregressionas“***”or“NS”insteadoftheiractualvalue.

0 UsingPROCFORMAT,youapplythisformatthencreateanExcel®filevia

WAIT.

PROCEXPORT

Page 5: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

2.ODSTAGSETS.EXCELXPODS TAGSETS.EXCELXP

FILE = "C:\Users\Deanna\Desktop\MY_FORMATTED_FILE.XLS"STYLE = MINIMAL;

PROC PRINT DATA = estimates NOOBS; VAR Variable Estimate StdErr Probt; FORMAT Probt SIGF.;

RUN; ODS TAGSETS.EXCELXP CLOSE;

Thanks,ODS!

Page 6: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

PROC TRANSPOSEDATA = sashelp.class out = class_w;VAR Age;

RUN;

3.PROCTRANSPOSEwithID0 YouneedtorearrangeyourdatasetusingPROC

TRANSPOSE,butthebasicsyntaxdoesnotnecessarilyproducethemostreadableoutput.

Page 7: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

PROC TRANSPOSEDATA = sashelp.class out = class_w;VAR Age;ID Name;

RUN;

3.PROCTRANSPOSEwithID0 AddingtheIDstatement totheprocedureyieldsa

morepresentabletable.

Page 8: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

4.CALLSYMPUT0 CALLSYMPUTprovidestheabilitytosavevalues–numbersorcharacterstrings– intomacrovariablesthatlatercanberecalled

Page 9: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

4.CALLSYMPUTPROC MEANS DATA = SASHELP.CLASS;VAR AGE;CLASS SEX;OUTPUT OUT = MY_MEANS;RUN;DATA _NULL_;SET MY_MEANS(WHERE = (_STAT_ = "N"));IF SEX=“F” THEN DO; CALL SYMPUT (“N_F",INPUT(AGE, 2.0));END;IF SEX=“M” THEN DO; CALL SYMPUT (“N_M",INPUT(AGE, 2.0));END;

RUN;

%PUT &N_F.; %PUT &N_M.;

910

Thankyou,SAS.So…whatnow?

Page 10: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

5.SGANNO0 Onecommonwaytodisplaysummarystatisticsis

throughchartsandgraphs.0 But,iftherearenoautomaticoptionsinthegraphics

procedure,howcanwegetthemeanvaluewesavedinCALLSYMPUTontoanice‐lookingboxplot?

0 WegetitthereviatheSGANNO=option.0 Note:IfyouprefernottousetheSGs,theequivalent

ANNO=optionisavailableforPROCGPLOTs,GMAPs,BOXPLOTs,etc.

0 AlthoughweuseSGANNOwithaCALLSYMPUTinourexample,theoptioncanbeusedmanyways.

Page 11: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

5.SGANNO0 First,createasetofinstructions,intheformofaSAS

dataset,thattellstheSASprocedurewhereandhowthedatawillbedisplayed.DATA SGANNO_DSET;

LENGTH LABEL 30;RETAIN WHEN "A" X1SPACE "DATAVALUE" Y1SPACE "DATAVALUE" TEXTFONT

"CALIBRI" WIDTH 40 JUSTIFY "CENTER“ FUNCTION "TEXT" TEXTCOLOR "BLACK" TEXTWEIGHT "BOLD" TEXTSIZE 14 Y1 18;

X1=0;LABEL=CAT("N="||TRIM(LEFT(&N_F.))||" students");OUTPUT;X1=1;LABEL=CAT("N="||trim(left(&N_M.))||" students");OUTPUT;

RUN;

PROC SGPLOT DATA=SASHELP.CLASS SGANNO=SGANNO_DSET;VBOX AGE/CATEGORY=SEX ;YAXIS MIN=8 MAX=20 INTEGER;

RUN;QUIT;

0 Then,feedthoseinstructionsintotheprocedure.

Page 12: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

5.SGANNO

Page 13: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

6.DICTIONARY.COLUMNS0 DuringaSASsession,DICTIONARYtablescanbeusedtoretrieveinformationrelatedtocurrentlydefined0 libnames,0 tablenames,0 columnnamesandattributes,0 formatsand…0 muchmore.

Page 14: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

6.DICTIONARY.COLUMNS0 DICTIONARY.COLUMNStableisusefulwhenyouwanttofindspecificcolumnstoincludeinyouranalysis

0 SimilartoPROCCONTENTS

Columnvs.variable

Page 15: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

7.PROCSQLSELECTINTO:0 HowdoweuseDICTIONARY.COLUMNS?

0 Let’slookatanexample…0 Whatwehave:19students’sex,age,heightandweightover3years(modifiedSASHELP.CLASS)

0 Whatwewant:Multipleyearsofdatainawidedataset

0 Whattodo:Mergeandrename

Page 16: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

7. PROCSQLSELECTINTO:

PROC SQL;SELECT CATT(NAME,"=", CATT(NAME, "_Y2")) INTO : VARS_Y2 SEPARATED BY " "FROM DICTIONARY.COLUMNSWHERE LIBNAME = "WORK" & MEMNAME = "CLASS_YEAR2”;

QUIT;

SAS,puttogether: eachvalueofthevariable“NAME”[fromDICTIONARY.COLUMNS]…

…followedbyanequalssign…

…followedbythenewvaluefor“NAME,”whichhasthesuffix_Y2.

(repeatforY3)

Page 17: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

7. PROCSQLSELECTINTO:0 Thedatastepbelowrenamesthevariablesinthedatasettotheircorrespondinglabels:

0 Voila.Done.Renamed.Needmoreevidence?Entera%PUTstatementtoseetheactualvalues(printedtotheLogwindow)storedinyourmacrovariable:

DATA STEP;MERGE CLASS_YEAR1

CLASS_YEAR2(RENAME = (&VARS_Y2.))CLASS_YEAR3(RENAME = (&VARS_Y3.));

BY NAME;RUN;

Macro variable VARS_Y2 resolves to Age=Age_Y2 Height=Height_Y2 Weight=Weight_Y2

%PUT &VARS_Y2.;

Page 18: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

COMMUNITIES.SAS.COM

Page 19: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

COMMUNITIES.SAS.COM

Page 20: 66 Slides MISUG forPDF.ppt [Read-Only]...2. ODS TAGSETS.EXCELXP 0 You want to present p‐values for the coefficients from a simple linear regression as “***” or “NS” instead

Thanksforyourtimeandattention

Source: www.xkcd.com