The LITI rule for Text Analytics that you didn’t know you needed…until now!
Recent Library Articles
Recently in the SAS Community Library: Customer complaint call transcripts can end up being quite verbose. SAS' @PeterChristie reveals how to distill relevant info using SAS Text Analytics.
Is there a place that documents when (year or release) a function or routine was added to SAS, and when it may have been bug fixed, altered, extended or deprecated?
... View more
Hi,
I am using proc sql left join to merge my two excels on based on two mutual columns they have.
here is the code I use:
proc sql; CREATE TABLE FINALV3 AS SELECT * FROM WNPOP LEFT JOIN pop2012 ON WNPOP.State_Name_All=pop2012.State_Name_All AND WNPOP.County_Name_All=pop2012.County_Name_All; QUIT;
while the proc happened and I can see the columns joined and the number of obs are correct, I do not have values in the joined columns. (THERE IS NO ERROR in the LOG ).
any ideas of what is going wrong?
... View more
I developed a user-friendly SAS macro application to perform all possible mixed model selection of fixed effects including quadratic and cross products within a user-specified subset range in the presence of random and repeated measures effects using SAS PROC MIXED (Fernandez, 2007). This macro application, ALLMIXED will complement the model selection option currently available in the SAS PROC REG for multiple linear regressions and the SAS Proc GLMSELECT that focuses on the standard independently and identically distributed general linear model for univariate responses. Options are also included in this macro to select the best covariance structure associated with the user-specified fully saturated repeated measures model; to graphically explore and to detect statistical significance of user specified linear, quadratic, interaction terms for fixed effects; and to diagnose multicollinearity, via the VIF statistic for each continuous predictor, involved in each model selection step. Two model selection criteria, AICC (corrected Akaike Information Criterion) and MDL (minimal description length) are used in all possible model selection and summaries of the best model selection are compared graphically. In this community posting, I will describe the prescreening step of ALLMIXED model selection steps.
ALL POSSIBLE MODEL SELECTION STEPS
The recommended selection steps for performing the model selection in MIXED model is illustrated in Figure1. Although the recommended sequence of the steps is identified in the figure 1, it is not a requirement to follow the same sequence. Users are free to choose to run any model selection steps in any order they desire. However, before running these model selection steps the data format must be suitable for running the SAS PROC Mixed procedure. The following types of PC data formats can be used with the ALLMIXED macro: SAS temporary and permanent data files, Microsoft excel, COMMA or TAB delimited text file.
SAS 9.4 Modules required to run this macro:
SAS/STAT: PROC MIXED, PROC CORR, PROC REG, PROC GLMSELECT
SAS/GRAPH: PROC GCHART, PROC GPLOT, PROC G3D
Base SAS ODS (RTF, HTML, PDF)
SAS/ACCESS: PC FILES – PROC IMPORT and PROC EXPORT
Improved ALLMIXED SAS macro application
The original SAS macro application, I developed (Fernandez, 2007) is not compatible in SAS enterprise guide (SAS EG) or in SAS studio. Therefore, I am presenting an improved version of the ALLMIXED macro in this post. By using this improved ALLMIXED macro application, SAS users can effectively perform complete mixed model analysis in SAS studio or in SAS EG. First download and unzip the ALLMIXED.zip file specified in this post and save the contents to a custom folder such as C:\temp\allmixed. The extracted ALLMIXED zip file should include, compiled ALLMIXED macro catalog, five macro call files corresponding to six ALLMIXED model selection steps, and sample demo data used in the demo. In this article, I will present the steps needed to perform Step2-Initial Covariance selection in this post. Please follow the steps outlined in the previous post to perform step1- Prescreening (https://communities.sas.com/t5/SAS-Communities-Library/User-friendly-SAS-application-for-performing-all-possible-mixed/ta-p/761068).
STEP2: Initial Repeated measures Covariance selection
In a repeated measures modeling, the best covariance structure describing the correlation among the repeated measures should be identified first. The best covariance structure can be identified from different user-specified covariance structures by comparing the AICC statistic computed in PROC MIXED using REML method and select the covariance type which gives the smallest AICC value. In this example, four different covariance types, CS, AR(1), TOEP, and UN are compared in the full saturated model containing two categorical effects (TRT and TIME) and 4 continuous fixed effects selected from the previous prescreening steps.
ALLMIXED SAS macro help – Step 2 Repeated measure covariance type selection
Input the Excel file name or SAS data set name?
Descriptions and Explanation: Include the data type name (XLS, TAB, TXT, SAS, TMP) and name of the data set on which you would like to perform pre-screening.
Options / Examples:
xls_SIMDATA1: Data type is EXCEL, and the file name is SIMDATA1. Make sure to include the separator character '_'.
SAS_SIMDATA1: Data type is permanent SAS (SD7SAS) and the SAS permanent data name is SIMDATA1
TMP_SIMDATA1: Data type is temporary SAS data and file name is SIMDATA1.
Input required Response variable or variables
Descriptions and Explanation: Input the continuous response (dependent) variable name (or names). The name should match the variable names in the data. You can include multiple responses
Options / Examples:
Y Y1 Y2
Pre-screening fixed variables using GLMSELECT
Descriptions and Explanation: To start the variable pre-screening mode, enter yes. Pre-screening based on the LASSO method using the selection method SBC and the stop criterion NONE will be performed. This field should be left blank to run all other model selection steps.
Options / Examples:
GLMSELECT=
Input optional CLASS terms
Descriptions and Explanation: Input the names of the categorical variables that will be included in the CLASS statement in PROC Mixed.
Options / Examples:
Class= TRT time sub
Input ith analysis (a counter) to attach to the saved output file name
Descriptions and Explanation: Input any numeric and categorical character to track the number of the analysis that you are running using this data. For example, if you input 1A, the output file created in this step would be called SIMDATA11A.ext.
Options / Examples:
Z = -1
Z = 1A
Repeated measure Statement
Descriptions and Explanation: Input the REPEATED statement and leave the covariance type blank.
Options / Examples:
• repeated time /sub=sub type=
Input the subject variable name
Descriptions and Explanation: In case of repeated measures data, input the subject variable name. This forces the pre-screening to do initial selection at the subject level.
Options / Examples:
Id, subject, or blank
Sub = Sub
List covariance structure(s) screening
Descriptions and Explanation: List all the repeated measures covariance types.
Options / Examples:
• Covari = CS AR(1) TOEP UN
Display or save the Graphs/output? choose one
Descriptions and Explanation: Option for viewing and saving all output files in a folder specified in input number 17.
WORD: Output and all SAS graphics are saved together in the user-specified folder as a single RTF format.
WEB: Output and graphics are saved in the user-specified folder as a single HTML file.
PDF: Output and graphics are saved in the user-specified folder and as a single PDF file.
TXT: Output is saved as a TXT file in all SAS versions. No output is displayed in the OUTPUT window. All graphic files are saved as PNG format in the user-specified folder.
Folder containing the PC data files
Descriptions and Explanation: Input the full path of the folder containing the source data file.
Options / Examples:
😧\allmixed\sasdata\ - folder name SASDATA on drive D
Make sure that you include the backslash (\) at the end of the folder name.
OUTPUT= c:\temp\allmixed\
Folder to save the output/graphics?
Descriptions and Explanation: To save the SAS graphics, data, and output files, input the output folder name. If the 14 field is left blank, the output files are saved in the default folder.
Options / Examples:
Dir2= C:\temp\allmixed\
In a repeated measures modeling, the best covariance structure describing the correlation among the repeated measures should be identified first. The best covariance structure can be identified from different
user-specified covariance structures by comparing the AICC statistic computed in PROC MIXED using REML method and select the covariance type which gives the smallest AICC value. In this example, four
different covariance types, CS, AR(1), TOEP, and UN are compared in the full saturated model containing two categorical effects (TRT and TIME) and four continuous fixed effects selected from the previous prescreening
steps. The results of initial covariance type selection are graphically displayed in Figure3 and based on ΔAICCj (AICCj - AICC min), AR(1) can be identified as the best covariance type. Therefore, AR(1)
covariance type will be used in the subsequent fixed effect selection. Refer the ALLMIXED2 macro help file available from the authors website for more information regarding inputting appropriate parameters.
Reference
Fernandez, G. (2007) Model Selection in PROC MIXED - A User-friendly SAS® Macro Application SAS Global Forum proceedings 191-2007
https://support.sas.com/resources/papers/proceedings/proceedings/forum2007/191-2007.pdf
... View more
I am creating a bar plot but would like to have the data labels inside the bars at the bottom. Here is my code so far. Thanks! PS. Also - when I insert the sas code here, how do I make it look like the original sas code (colors)? 🙂 data test;
input id group var;
cards;
1 1 2.236
2 1 4.569
3 2 3.694
4 2 1.256
;
proc sgplot data=test;
vbar group / response=var stat=mean datalabel group=group fillattrs=(color=royalblue) DATALABELATTRS=(size=14);
xaxis display=(noline noticks) labelattrs=(size=16) valueattrs=(size=16) ;
yaxis display=(noline) labelattrs=(size=16) valueattrs=(size=16);
keylegend / noborder location=outside position=bottom valueattrs=(size=12);
format var 6.2;
title height=16pt 'var by group';
run;
quit;
... View more
I am trying to create a variable that will indicate if both LDOS and FDOS are :
after span_end_2
and before after_cutoff_2
and before span_end_3.
The issue I have is that in most cases, span_end_3 is blank/. in which case the current code I have below will treat LDOS and FDOS as > span_end_3. I need to fix my code so sas will treat LDOS and FDOS as < span_end_3 when span_end_3 is blank. Is there a way to do this?
data have;
input
ID$ LDOS :DATE9. FDOS :DATE9. Span_Begin_1 :DATE9. Span_End_1 :DATE9. Span_Begin_2 :DATE9.
Span_End_2 :DATE9. Span_Begin_3 :DATE9. Span_End_3 :DATE9. after_cutoff_2 :DATE9. ;
format FDOS MMDDYY10. LDOS MMDDYY10. Span_Begin_1 MMDDYY10. Span_End_1 MMDDYY10. Span_Begin_2 MMDDYY10.
Span_End_2 MMDDYY10. Span_Begin_3 MMDDYY10. after_cutoff_2 MMDDYY10.;
datalines;
5 20Apr2023 20Apr2023 1Jul2022 29Jul2022 21Nov2022 4Apr2023 . . 3Apr2024
5 24Apr2023 24Apr2023 1Jul2022 29Jul2022 21Nov2022 4Apr2023 . . 3Apr2024
5 25Apr2023 25Apr2023 1Jul2022 29Jul2022 21Nov2022 4Apr2023 . . 3Apr2024
5 1May2023 1May2023 1Jul2022 29Jul2022 21Nov2022 4Apr2023 . . 3Apr2024
;;;
run;
data want;
set have;
if LDOS gt Span_end_2
and FDOS gt Span_end_2
and LDOS lt after_cutoff_2
and FDOS lt after_cutoff_2
and LDOS lt Span_end_3
and FDOS lt Span_end_3
then After_Span2=1;
else After_Span2=0;
run;
... View more