Desktop productivity for business analysts and programmers

Help with re-formatting a table in Enterprise Guide

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Help with re-formatting a table in Enterprise Guide

I have a table with variable names (string values) in column form that come from a user input.  There is always 1 column with the header called "Name" but the number of rows in the column is undefined (based on user input, the variable list is currently called by the macro &THRES_VARS).

Example Data:

Name

Variable1

Variable2

Variable3

I need the resulting output to be a 1 column 1 row table that looks like this:

Variable1+Variable2+Variable3

Does anyone know how to produce code/macro to produce the output?


Accepted Solutions
Solution
‎12-27-2012 03:05 PM
Grand Advisor
Posts: 17,338

Re: Help with re-formatting a table in Enterprise Guide

assuming you literally want it separated by "+"

Here's one way via code.  You can change the delimiter as you like as well.  Make sure the initial length of the variable is long enough to hold the resulting string.

firstobs is set to 2 so that the name is not included.

data want;

length variable $512;

set have (firstobs=2) end=eof;

retain variable;

variable=catx("+", variable, your_variable);

if eof then output;

run;

View solution in original post


All Replies
Solution
‎12-27-2012 03:05 PM
Grand Advisor
Posts: 17,338

Re: Help with re-formatting a table in Enterprise Guide

assuming you literally want it separated by "+"

Here's one way via code.  You can change the delimiter as you like as well.  Make sure the initial length of the variable is long enough to hold the resulting string.

firstobs is set to 2 so that the name is not included.

data want;

length variable $512;

set have (firstobs=2) end=eof;

retain variable;

variable=catx("+", variable, your_variable);

if eof then output;

run;

New Contributor
Posts: 2

Re: Help with re-formatting a table in Enterprise Guide

That is exactly what I needed.  Thanks so much.

☑ This topic is SOLVED.

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

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