Recently in the SAS Community Library: SAS' @StuartRogers provides a close look at the new Microsoft Entra Gallery application and details how it can be used.
I've been looking for a good, efficient method to create "Table 1", which has a more or less standard format in research journals:
Variable Name
Category 1
Category 2
P-value
Variable 1
1
N(%)
N(%)
Chi-sq or Fisher's
2
N(%)
N(%)
3
N(%)
N(%)
Variable 2
Mean (SD)
Mean (SD)
t-test
Median (IQR)
Median (IQR)
I found this PDF paper. It seems to work pretty well, but I'm having 2 issues. The first is that the chi-square results are saved into a file and then merged into the main file. But the value of the "variable" variable is the var label in 1 file and the var name in the other, so they don't merge.
The second issue is that Proc Report does not produce a table and instead gives me this: NOTE: Groups are not created because the usage of levels is DISPLAY. To avoid this note, change all GROUP variables to ORDER variables.
WARNING: A GROUP, ORDER, or ACROSS variable is missing on every observation.
data have;
infile datalines dsd dlm=',' truncover;
input DEM_AGE DEM_SEX cohort_flag TM_group;
datalines;
3,1,1,0
2,1,1,1
3,2,1,1
3,2,1,1
3,2,1,0
2,2,1,1
2,1,1,1
3,1,1,1
2,1,1,1
3,2,1,0
2,1,1,0
2,2,1,1
3,2,1,0
2,2,0,
3,2,1,1
3,2,1,1
3,1,1,0
3,2,1,0
2,1,1,0
3,1,1,1
3,2,1,1
3,2,1,0
3,2,1,1
3,2,1,1
3,2,1,1
; RUN;
/*Load formats from existing file in temp folder*/
options fmtsearch=(temp.formats);
/*DEM_SEX sex 1 Male 2 Female*/
/*DEM_AGE AGE2GRP 1:Age Group <65 2:Age Group [65,75) 3:Age Group >=75*/
/*TM_group yesno 1 Yes 2 No*/
/*Generate descriptive statistics*/
proc means data = temp.have noprint n sum mean;
class DEM_AGE DEM_SEX;
var TM_group /*MA_group*/;
ways 1;
output out = temp.expl_PreTable n =
sum =
mean = / autoname;
WHERE cohort_flag = 1;
run;
/*Format descriptive stats*/
data temp.expl_Table (keep = variable levels TM_group_N TM_group_sum
TM_group_mean pct ExpPct indexvar); set temp.expl_PreTable;
length variable $ 20; /* These four variables */;
length levels $ 20; /* will describe the first */;
length pct $ 8; /* four columns of the table */;
length ExpPct $ 15;
if DEM_AGE ne . then do; /*Building "variable" and "Levels" columns for "DEM_AGE"*/;
variable = 'Age category';
levels = put(DEM_AGE, age2grp.);
IndexVar = 1; /*This index is included just in case the order of data presentation needs to be changed*/;
end;
if DEM_SEX ne . then do; /*Building "variable" and "Levels" columns for "DEM_SEX"*/;
variable = 'Sex';
levels = put(DEM_SEX,sex.);
IndexVar = 2;
end;
pct = put(TM_group_mean*100,4.1); /*Calculate % exposed */;
ExpPct = compress(put(TM_group_sum,comma4.),' ')
||' '||'('||compress(pct,' ')||')'; /*creating data in the form of "count (%)" */;
run;
/*Run chi-square significance tests and use ODS to create a dataset of these results*/
ods trace on;
ods output chisq = temp.expl_ChiData;
proc freq data = temp.have;
table TM_group*DEM_AGE / chisq;
table TM_group*DEM_SEX / chisq;
WHERE cohort_flag = 1;
run;
ods trace off;
/*Rearrange chi-square dataset so it can be merged with descriptive stats table*/
data temp.expl_ChiData2 (keep = variable prob);
set temp.expl_ChiData (where = (statistic = 'Chi-Square'));
length variable $ 20;
variable = scan(table,-1,' '); /* Returns the last word in a character value from the "table" variable*/
run;
/*Sort both tables so they will merge*/
PROC SORT data=temp.expl_Table OUT=temp.expl_Table_sort; BY variable; RUN;
PROC SORT data=temp.expl_ChiData2 OUT=temp.expl_ChiData2_sort; BY variable; RUN;
/**************MERGE DOES NOT WORK BECAUSE The value of the "variable" variable is the var label in 1 file
and the var name in the other. DUE TO THE 'IF a' STATEMENT, NOTHING FROM THE CHIDATA2 FILE IS MERGED IN****/
/*Merge descriptive stats table with chi-square table*/
DATA temp.expl_TableData;
MERGE temp.expl_Table_sort (in = a) temp.expl_ChiData2_sort (in = b);
BY variable;
IF a;
RUN;
/*Use PROC REPORT to create final output table*/
proc report data = temp.expl_TableData nowd;
column variable levels TM_group_N ExpPct prob;
define variable / "Variable" group format = $variable.;
define levels / " " ;
define TM_group_N / "TM" /*format = comma5.*/;
define ExpPct / "TM Group/n (%)";
define prob / "p-value" group format = pvalue6.4;
Title "Table 1. Descriptive characteristics of individuals in the sample";
RUN;
... View more
Hello, everyone
I managed to estimate the parameters for a Weibull accelerated failure time model from the PROC LIFEREG procedure. I have the point and interval estimations for predictor coefficients. In addition, I have the estimations for the Weibull shape parameter.
After I get these estimations, I would like to simulate the cumulative incidence curve/survival curve. I know I should use the point estimation of these coefficients and the shape parameter in the prediction model. But I am not sure whether to use the interval estimation of coefficients, or the shape parameter.
You answer is much appreciated!
... View more
My boss just informed me that SAS is not free to use, which blew my mind to be honest. I thought the only reason why people put up with it was because it was easily accessible, but to learn that it’s actually super expensive just makes me wonder why so many people still use it. For me personally, SAS is a huge pain in the ass when it comes to data manipulation. I don’t like not being able to see the result of coding as I go along, like I would in R or even Python. Not to mention, it doesn’t run on Mac systems, and their free university software (that I’ve been using) does not allow you to copy and paste. It also automatically logs you out after 15 mins of nothingness, WITHOUT AUTOSAVING, which is incredibly stressful. I do love running multivariate categorical analyses in SAS though. How about you all? Would love to hear your experiences and opinions.
... View more
I am running the following code to subset an existing table as part of a data engineering pipeline. I want to reduce outputs to the log from proc cas. proc cas ;
table.Partition/ casout={caslib="mycaslib" name="previous_errors" replace=True}
table={caslib="mycaslib" name= "&viewName._DQ" where="DQField= error"};
quit; This will then print to the log the following: {caslib=mycaslib,tableName=PREVIOUS_ERRORS,rowsTransferred=0,shuffleWaitTime=0.000010252,minShuffleWaitTime=0,maxShuffleWaitTime=2.1457672E-6,averageShuffleWaitTime=1.4645713E-6} This is very frustrating as this code is part of a macro running close to 100 times, so this message is really unnecessarily clogging up the log. Does anyone know how to turn it off? I already have messageLevel set to "warning", which I have checked using "listsessopts" I am using SAS Viya 3.5.
... View more
I am configuring Oracle on new 9.4 M8 and below are the entries I made in sasenv_local after having Oracle configured on Linux. everything looks good as per SAS documentation but still getting the error. Can you please suggest where things are going wrong?
Note : I have restarted Connect and Share services after updating sasenv_lcoal.
libname mydblib oracle user=uname password=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ! path=<mypath from tnsnames.ora>; ERROR: Unable to load oracle client (libclntsh.so) ERROR: Error in the LIBNAME statement.
sasenv_local entries:
ODBCHOME=/sas/sashome/AccessClients/9.4/SQLServer export ODBCHOME
ORACLE_HOME=/sas/oracle/product/12.2.0/dbhome_1 export ORACLE_BASE=/sas/oracle export PATH=$ORACLE_HOME/lib:$PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH
echo $PATH /sas/sashome/SASFoundation/9.4:/sas/oracle/product/12.2.0/dbhome_1/lib:/sas/sashome/SASFoundation/9.4:/sas/oracle/product/12.2.0/dbhome_1/bin:/home/sas/.local/bin:/home/sas/bin:/usr/share/centrifydc/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sas/config/Lev1/Applications/SASGridManagerClientUtility/9.4/
echo $LD_LIBRARY_PATH /sas/sashome/AccessClients/9.4/SQLServer/lib:/sas/oracle/product/12.2.0/dbhome_1/lib
... View more