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
SAS Super FREQ
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 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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