BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User
Or no need to make macro variable , just keyword  _row_ enough.


column ..........  dummy ; <---- the last variable
.........
define dummy/ computed NOPRINT ;

compute dummy;
 /*Put all call define in it ,and don't make so many compute block*/

N+1;
If Mod(N,2)=1 Then Do;
  Call Define(_row_,"Format","PValue.");
  Call Define(_row_,"Style","Style={BackGround=CorrSec.}");
End;

endcomp;


turcay
Lapis Lazuli | Level 10

Thank you very much @Ksharp, you helped me so much. After I change my code as below, it worked . What do you think? Does it seem dynamic and proper? I think I won't face any errors in future, If I use this code?

 

Ods Escapechar='~';
Options Missing=' ';
Proc Report Data=Spr2_&Suffix. Nowd SpanRows Style(Column)=[BorderColor=Black BorderWidth=1px]
Style(Header)=Header [BorderColor=Black BorderWidth=1px];
Column ("Spearman Correlation Coefficients, N = &Nobs
~n  Prob > |r| under H0: Rho=0" Variable &ModelVar. Dummy);
Define Variable /Order ' ' Style(Column)=Header{VJust=C FontWeight=Bold Color=#112277} ;
%MakeDefine;
Define Dummy / Computed NoPrint;
Compute Dummy;
N+1;
If Mod(N,2)=1 Then Do;
%If &Count. GT 0 %Then %Do;
  %Do j = 1 %to &Count.;
   %Let Var&j = %Scan(&ModelVar.,&j,%str( ));
   %Put Var&j= &&Var&j;
  Call Define("&&Var&j","Style","Style={BackGround=CorrSec.}");
   %End;
%End;
End;
Else Do;
%If &Count. GT 0 %Then %Do;
  %Do j = 1 %to &Count.;
   %Let Var&j = %Scan(&ModelVar.,&j,%str( ));
   %Put Var&j= &&Var&j;
  Call Define("&&Var&j","Format","PValue.");
     %End;
%End;
End;
EndComp;
Run;

Thank you

Ksharp
Super User
Yeah. Code looks good and I hope so.


turcay
Lapis Lazuli | Level 10

Thank you for your sensitivity and attention

Cynthia_sas
Diamond | Level 26
I would not use the %PUT in production code where you are generating PROC REPORT. It will add significantly to the log with text that the user will not understand. If you are the only one using this code, then use the %PUT for debugging. But if you are turning this code over to someone else to run, I would recommend removing the %PUT statement.

cynthia
turcay
Lapis Lazuli | Level 10

Thank you very much @Cynthia_sas. I will consider your suggestions 🙂

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 50 replies
  • 7901 views
  • 5 likes
  • 4 in conversation