DATA Step, Macro, Functions and more

joining and formatting two variables using cat

Accepted Solution Solved
Reply
Regular Contributor
Posts: 180
Accepted Solution

joining and formatting two variables using cat

Hi!

 

I need some help trouble shooting a little piece of my code.  I'm getting error, but not sure why...

 

I need the output to look like mean(std)  or  x.x(x.xx)  --

 

sord=2;
_1=cat(strip(put(mean, 8.1)), ' (' strip(put(std, 10.2))')');
output;

 

 

and second, the next output to look like Min,Max  x,x 

 

 sord = 4;
_1=cat(strip(put(MIN,8.)),", "(put(MAX,8.)));
output;

 

I'm getting syntax errors an probably missing a parenthesis somewhere...but please help!  thx!

 

 


Accepted Solutions
Solution
‎11-29-2017 12:30 PM
Super User
Posts: 22,875

Re: joining and formatting two variables using cat

If it's parenthesis, count them. 

I think you're missing comma's actually - put each item on it's own line to see this, with the comma at the front of the item.

 

Use CATT or CATS instead of CAT.

 

_1=cat(
    strip(put(mean, 8.1))
, ' (' 

<MISSING COMMA HERE>

strip(put(std, 10.2))
<MISSING COMMA HERE>

')'

);

 

 

View solution in original post


All Replies
Solution
‎11-29-2017 12:30 PM
Super User
Posts: 22,875

Re: joining and formatting two variables using cat

If it's parenthesis, count them. 

I think you're missing comma's actually - put each item on it's own line to see this, with the comma at the front of the item.

 

Use CATT or CATS instead of CAT.

 

_1=cat(
    strip(put(mean, 8.1))
, ' (' 

<MISSING COMMA HERE>

strip(put(std, 10.2))
<MISSING COMMA HERE>

')'

);

 

 

Regular Contributor
Posts: 180

Re: joining and formatting two variables using cat

thank you!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 109 views
  • 0 likes
  • 2 in conversation