Hi all,
Today, I found a discussion to generate a publication-quality table by using SAS. From the highest voted answer in this discussion of @ciro , I notice something as below, I really appreciate if you can hint me what do they mean:
This is the code:
PROC IMPORT OUT= WORK.PARM DATAFILE= "G:\temp\parm.xls" DBMS=EXCEL REPLACE;
RANGE="parm";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
/*write a dataset with standard error on the same column of coefficient*/
data parm2;
set temp.parm;
if not missing(stderr) and variable not in ('R-square','Adj.R-sq','N. Obs.') then do;
value=estimate; type='coefficient'; output; end;
if not missing(stderr) then do; value=stderr; type='stderr' ;output; end;
if variable in ('R-square','Adj.R-sq','N. Obs.') then do; value=estimate; type=variable ;output; end;
run;
proc format;
picture stderrf (round)
low-high=' 9.9999)' (prefix='(')
.=' ';
run;
ods html close;
ods html;
title;
proc report data=parm2 nowd out=temptbl;
*column model numord variable type dependent, value;
column numord variable type dependent, (value probt);
define numord /group order=data noprint;
define variable / group order=data ' ';
define type / group order=data noprint;
define dependent / across ' ';
define value /analysis sum;
define probt /analysis sum;
compute value;
array cc _c5_ _c7_ _c9_ ;
if type='stderr' then do;
call define(_col_,'format','stderrf.');
end;
else if type='coefficient' then do;
call define(_col_,'format','8.4');
do i=1 to 3;
if 0.05<cc(i) <= 0.1 then call define(_col_, "style", "style=[ posttext='*']" );
else if 0.01 <cc(i) <=0.05 then call define(_col_, "style", "style=[ posttext='**']" );
else if cc(i) <= 0.01 then call define(_col_, "style", "style=[ posttext='***']" );
end;
end;
endcomp;
run;
I know some of you do not want to open the excel file outside so I post the picture for the parm.xls here:
1> What is the purpose of using temp in set statement? (set temp.parm;)
I do not understand the meaning of using temporary dataset input, why would we do that?
2> I have the same questions with @jtobin about where they got the "cc" array. I read the answer of @Reeza about that but it is still ambiguous to me. What I want to ask here is: which column of the dataset parm is associated with cc?
3> To generate an excel file like parm, what are two variables: Probt and numord in my statistical output as below? I guessed Probt is the column Pr>|t| aka p-value and numord seems to be associated with the order of variables in column variable; however, why numord or R-square and else are up to 1000,1001,2000?
Thank you and warm regards.
Edit reason: Update the guess in numord and Probt.
temp is just a libref but given that there is no libname statement in the code and the proc import writes to work and not temp it's likely as @Tom states just a left over.
You could make this bit of the code work as is by adding the following on top of the code which creates libref temp pointing to work.
libname temp "%sysfunc(pathname(work))";
Most likely a typo in the program.
The previous step is converting an Excel sheet into a dataset named WORK.PARM.
Hi @Tom
Thank you for your comment, and I agree with you that it is a typo error because it announces an error when I let the temp over there, so I decided to delete the temp. word.
42 /*write a dataset with standard error on the same column of coefficient*/
43 data parm2;
44 set temp.parm;
ERROR: File TEMP.PARM.DATA does not exist.
temp is just a libref but given that there is no libname statement in the code and the proc import writes to work and not temp it's likely as @Tom states just a left over.
You could make this bit of the code work as is by adding the following on top of the code which creates libref temp pointing to work.
libname temp "%sysfunc(pathname(work))";
Regarding your question about this:
array cc _c5_ _c7_ _c9_ ;
The array here references PROC REPORT columns NOT SAS dataset variables. In this procedure you can code logic using the columns being created in the report so _C1_ refers to first column reading from left to right in the report. _C5_ is the fifth column.
Thank you @SASKiwi
I have a look on the element of an array here, can I ask a question whether cc is the name of this array, please?
Thanks in advance,
Phil.
>. whether cc is the name of this array, please?
yes it is
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.