BookmarkSubscribeRSS Feed
helloSAS
Obsidian | Level 7

Hi,

 

I want to prefix field values with a tab. (NOTE: It cannot be spaces). Currently I'm using below logic.  Field "Sep" should have a vlaue of tab.

 

Data test;

set qa_accts;
sep=' '; /*** THIS SHOULD BE TAB ***/
ends=''; /** THIS SHOULD BE SPACE **/
var1='V$_dpd';
dpd = actual_dpd;
ltr_variable_data = catx(sep,var1,dpd,ends);

run;

 

 

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

Please try tab space with "09"x

Data test;
set qa_accts;
sep='"09"x; /*** THIS SHOULD BE TAB ***/
ends=''; /** THIS SHOULD BE SPACE **/
var1='V$_dpd';
dpd = actual_dpd;
ltr_variable_data = cat(sep,var1,dpd,ends);
run;

, but again if you are concatenating the variables with catx function, this function will strip the blank spaces in the new variable created i.e., ltr_variable_data. so the best way to avoid it is just use cat function instead of catx. It does not strip or trim the spaces and keeps the spaces as is in the new variable.

Thanks,
Jag
helloSAS
Obsidian | Level 7

Thanks! I used cat function but var1 is having trailing blanks. How to remove them?

 

 

Jagadishkatam
Amethyst | Level 16
Yes i agree with @Reeza, you could use either of the functions to remove the trailing blanks
Thanks,
Jag

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2239 views
  • 0 likes
  • 3 in conversation