BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Phil_NZ
Barite | Level 11

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:

Phil_NZ_0-1620257948025.png

 

 

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?

Phil_NZ_0-1620259922371.png

 

Thank you and warm regards. 

Edit reason: Update the guess in numord and Probt.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

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))";

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

Most likely a typo in the program.

The previous step is converting an Excel sheet into a dataset named WORK.PARM. 

Phil_NZ
Barite | Level 11

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.

 

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
Patrick
Opal | Level 21

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))";
SASKiwi
PROC Star

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.

Phil_NZ
Barite | Level 11

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.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
ChrisNZ
Tourmaline | Level 20

>. whether cc is the name of this array, please?

 

yes it is

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1213 views
  • 6 likes
  • 5 in conversation