BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TMiles
Quartz | Level 8

Help!!  I need to create a Tab Delimeted File with several blank columns and a final column that is the concatenation of 6 vars I am having 2 issues:

 

1. even though I have coded a Tab , the output also has a Comma Delimeter

2. I need to get rid of the blank space after the variable and before the text

 

Here is my code and I am attaching the output and a small sasfile i am testing with:

 
data _null_;
  set lago;
  tabdlm='2C'x;
  file out1 lrecl=32767;
  put
   '123456'tabdlm
   sku tabdlm
   'D31720' tabdlm
   description tabdlm 
   tabdlm 
   tabdlm 
   tabdlm 
   tabdlm 
   tabdlm 
   tabdlm           
   tabdlm           
   tabdlm           
   tabdlm           
   tabdlm           
   'croas=' croas 
   '\units=' units 
   '\demand=' ___K_s_
   '\woos=' wk_OOS 
   '\categ=' categ 
   '\yoi=' yrs_inv
 ;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Taking your questions in order ...

 

You didn't ask for a tab.  You asked for a comma.  2C is the hex code for a comma.  Off the top of my head, 09 is the hex code for a tab, but you'll have to check that.  If that's correct, use   tabdlm='09'x;

 

When the PUT statement encounters a variable name without a format, it leaves a single blank after the variable's value.  You have to tell SAS to back up, and write over that single space:

 

put '123456'  tabdlm +(-1)  sku +(-1) tabdlm +(-1)      etc.;

 

For constant text, such as "123456" there is no extra blank so don't add +(-1) there.

 

For safety's sake, leave a space after closing quotes.  A "t" immediately following a closed quote has the potential to cause problems.

 

That should do it.  Good luck.

View solution in original post

3 REPLIES 3
TMiles
Quartz | Level 8

Well I have egg on my face over that one!   yes i had the comma not the tab -ugh...   Thank you for seeing the obvious because for the life of me I couldn't 🙂

Astounding
PROC Star

Taking your questions in order ...

 

You didn't ask for a tab.  You asked for a comma.  2C is the hex code for a comma.  Off the top of my head, 09 is the hex code for a tab, but you'll have to check that.  If that's correct, use   tabdlm='09'x;

 

When the PUT statement encounters a variable name without a format, it leaves a single blank after the variable's value.  You have to tell SAS to back up, and write over that single space:

 

put '123456'  tabdlm +(-1)  sku +(-1) tabdlm +(-1)      etc.;

 

For constant text, such as "123456" there is no extra blank so don't add +(-1) there.

 

For safety's sake, leave a space after closing quotes.  A "t" immediately following a closed quote has the potential to cause problems.

 

That should do it.  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
  • 3 replies
  • 887 views
  • 5 likes
  • 3 in conversation