Help using Base SAS procedures

Building a Table with Column+CATX?

Accepted Solution Solved
Reply
Senior User
Posts: 1
Accepted Solution

Building a Table with Column+CATX?

Hi All - Long time lurker, first time poster. Normally googling is enough to answer any questions I have, but I'm having a hard time locating this one (I'm worried it's because the answer is so obvious no one ever bothers to ask). Apologies in advance as I fumble through this. 

 

In my work, I use SAS Enterprise Guide 7.1, relying mostly on the query building tool, but I occasionally mix in programs where the ask is beyond the standard Enterprise Guide functionality. I'm self taught so my knowledge is pretty remedial. I'm trying to build a step where I can concatenate a series of columns in addition to including other non-concatenated columns. I don't want to do it in the Query Builder because this is a project I run regularly and the number of columns might vary from project to project, so I'm trying to take out the manual-aspect of it. 

 

I've figured out how to do the CAT step, but being a programming newbie I'm not sure how to incorporate an additional column (outside of the CATX), my output is just the CATX column. 

 

I have googled the heck out of it, and I'm sure it's something simple, but because I'm self taught I think I'm just not experienced enough to figure it out. 

 

 

What I have: 

COLUMNA | Column1 | Column2|Column 3


What I want:

COLUMNA | CATX(COLUMNS1-3)

 

What I am getting:

CATX(COLUMNS1-3)

 

Here's my code to get the last one, I just need to figure out how to bring COLUMNA in, in addition to my concatenated column which is coming through great:

 

data WANT (keep=Column);
length Column $200;
set HAVE;
Column = catx(',',of Column:);
run;

Thanks in advance for any help you might be able to offer, and sorry again if this is a super remedial question. 

 


Accepted Solutions
Solution
‎05-15-2017 03:09 PM
PROC Star
Posts: 7,363

Re: Building a Table with Column+CATX?

Your resulting file only contains the column named COLUMN because you told SAS to ONLY keep that column

data WANT (keep=Column);

If you wanted to keep everything, just use:

data WANT;

Art, CEO, Analyst Finder.com

View solution in original post


All Replies
Solution
‎05-15-2017 03:09 PM
PROC Star
Posts: 7,363

Re: Building a Table with Column+CATX?

Your resulting file only contains the column named COLUMN because you told SAS to ONLY keep that column

data WANT (keep=Column);

If you wanted to keep everything, just use:

data WANT;

Art, CEO, Analyst Finder.com

☑ This topic is SOLVED.

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

Discussion stats
  • 1 reply
  • 141 views
  • 0 likes
  • 2 in conversation