BookmarkSubscribeRSS Feed
sasboy007
Calcite | Level 5

Hi all,

I'm trying to create the below concat and dump into a column.  But instead of adding the macro variable into the concat statement and filling down on the column it's creating a new column header and placing that macro variable into it.  Any help is appreciated.  Thanks.  Below is my code:

tmp = (left(trim(put(&var1,2.))))  ||  (left(trim('-'))) ||  (left(trim(put(dateStart,6.))))  || (left(trim('-'))) || (left(trim(put(dateEnd,6.))));

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Would need to see the code in context.  You can compress your code down also by doing:

tmp=catx('-',put(&var1.,2.),put(datestart,6.),put(dateend,6.);

Also note to put the point after macro variable, doesn't normally matter, but its on of those good practice things.

sasboy007
Calcite | Level 5

data test;

length tmp $16;

set newFile;

dateStart= &pStart.;

dateEnd = &pEnd.;

tmp = (left(trim(put(&var1,2.))))  ||  (left(trim('-'))) ||  (left(trim(put(dateStart,6.))))  || (left(trim('-'))) || (left(trim(put(dateEnd,6.))));

run;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

+1 to Astounding.  Also, try the catx version rather than all the left trim and hyphen combinations.

Astounding
PROC Star

Two questions ...

(1) Are you sure?  Because of the LENGTH statement, TMP would be the first variable in TEST.  Are you looking in the right place?

(2) What is the value assigned to &VAR1?

Good luck.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 951 views
  • 0 likes
  • 3 in conversation