BookmarkSubscribeRSS Feed
Phil_NZ
Barite | Level 11

Hi all SAS Users,

By searching, asking, consulting you, now I may go to the final step of getting the code for publication-style report. I hope this discussion also benefits other people who want to convert from STATA code to SAS code totally.

The last code working well so far is:

Input:parm.xls (I also attach the excel file in this post)

Phil_NZ_0-1620278369510.png

Code:

 

PROC IMPORT OUT= WORK.PARM  DATAFILE= "C:\Users\pnguyen\OneDrive - Massey University\PhD JOURNEY\leniency & operating\test_present\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 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 file="c:\temp\MyHTMLfile.htm";;
title;
proc report data=parm2 nowd  out=temptbl;
*column model numord variable type dependent, value;
column numord variable type dependent, (value);
define numord /group order=data noprint;
define variable / group order=data ' ';
define type / group order=data noprint;
define dependent / across ' ';
define value /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;

Output:

Phil_NZ_1-1620278411868.png

However, it works well only if the three columns have all 6 variables from X1 to X6 and the intercept.

I have two question here which irritate me:

1. How can we change the display of "value" in second, third, and fourth column on the Output Table (under Y1,Y2,Y3 respectively) to "aaa", "bbb", "xyz" ?

2. When I adjust the input by delete X3-X6 associated with dependent Y1, X4-X6 associated with dependent Y2 as the input below:

input:palmz (I also attached the file)

Phil_NZ_2-1620278989700.png

 

I run the same code as above and my output is:

Phil_NZ_3-1620279043701.png

 

I am wondering how can I push the R-square, Adj.R-sqr, and N.Ods to the bottom of the Output Table and how to blank the yellowed cells.

Many thanks and warmest regards,

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 0 replies
  • 1750 views
  • 0 likes
  • 1 in conversation