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;
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.
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 🙂
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.