Spacing issues with numeric variables

Reply
Frequent Contributor
Posts: 131

Spacing issues with numeric variables

Hi:

I created character variables as follows:

"mean(standard deviation)" from numeric variables.  The character variables include spaces inside the parantheses which I didn't include.  How best to clean these variables?

My code is here:

%macro restructure (var, level);

data mean_&var.&level.;

set mean_&var.;

if &var. ne "&level." then delete;

if &var.="&level." then &var.&level.=round(mean, .1)||"("||(round(stddev, .1))||")";

run;

proc print data=mean_&var.&level.;

var &var variable &var.&level.; run;

%mend;

some sample output:

Thanks very much!

Respected Advisor
Posts: 3,156

Re: Spacing issues with numeric variables

Use CATS to remove blanks and make your code more reader friendly:

if &var.="&level." then &var.&level.=cats(round(mean, .1),"(",round(stddev, .1), ")");

Ask a Question
Discussion stats
  • 1 reply
  • 139 views
  • 0 likes
  • 2 in conversation