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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 895 views
  • 5 likes
  • 3 in conversation