Hi all!
How can i export a data if have spaces at the and. I need this blank spaces at the end. I have a table with one cloumn (length $141.)
If i export the table to a txt cut the blank spaces at the end of the line and take a tabulator. How can i avoid this?
my code:
data _null_;
set table ;
call execute('proc export
data=x_table
outfile="C:\temp\sample.xt"
dbms=tab replace ;
putnames=no;
run;');
run;
now i have in the txt :
1 2 3 4 xyz XYZ(after that TABULATOR)
and i need this:
1 2 3 4 xyz XYZ(after the i need spaces until that i reach the $141. length)
Thank for all help!!
Well, all I can think of is to put out the data yourself.:
data _null_; set x_table; file "...abc.txt"; put vara $141. varb $50...; run;
Whether that puts spaces at the end, you would have to check, don't see why it should matter however,
abc $
abc$
With $ being the end of line, are exactly the same?
I am not sure .
filename x "C:\temp\sample.xt" lrecl=200;
proc export
data=x_table
outfile=x
dbms=tab replace ;
putnames=no;
run;
thanks but it doesn't work 😕
Sorry, your post makes no sense. Why are you call executing something with no changes to the code:
proc export data=x_table outfile="C:\temp\sample.xt" dbms=tab replace; putnames=no; run;
Is exactly the same?
Also, what is an xt file? Maybe a typo.
Please clarify what you mean by "after the i need spaces until that i reach the $141. length)" as adding in spaces after the end of the data makes no sense, there is nothing after XYZ to indicate the string stops?
Sorry for my wording. I attached 2 file. The "bad" one is the actual state. The "good" one is what i want to make.
1. I have one table with 1 columns this column length is $141. (x_table)
2. I have to export to a txt file.
3. If i use this code I get the good.txt file:
proc export data=x_table outfile="C:\temp\sample.txt" dbms=tab replace; putnames=no;run; (line(s) ending with linebrake instead of spaces)
so if i have in a table a $100. length line in the output .txt file have to take +41 spaces to fill the line.
soory for my bad english.
Thanks for your help!
Gergő
Well, all I can think of is to put out the data yourself.:
data _null_; set x_table; file "...abc.txt"; put vara $141. varb $50...; run;
Whether that puts spaces at the end, you would have to check, don't see why it should matter however,
abc $
abc$
With $ being the end of line, are exactly the same?
Yes,
abc $
abc$ is the same. Just i have to put spaces after "abc" until i reach the 141. place. How can i code this problem?
Thanks
@ger15xxhcker wrote:
Sorry for my wording. I attached 2 file. The "bad" one is the actual state. The "good" one is what i want to make.
1. I have one table with 1 columns this column length is $141. (x_table)
2. I have to export to a txt file.
3. If i use this code I get the good.txt file:
proc export data=x_table outfile="C:\temp\sample.txt" dbms=tab replace; putnames=no;run; (line(s) ending with linebrake instead of spaces)
so if i have in a table a $100. length line in the output .txt file have to take +41 spaces to fill the line.
soory for my bad english.
Thanks for your help!
Gergő
Line "length" is kind of a hazy concept when using dbms=TAB as tab characters are variable in appearance depending upon the viewing program.
I am not sure I really understand the problem but perhaps using an appropriate LRECL and RECFM=F such as
filename outfl ="C:\temp\sample.txt" lrecl=141 recfm=F;
and use in your output:
proc export data=x_table outfileoutfl dbms=tab replace; putnames=no;run;
In a data step LRECL plus the PAD option should also write blanks to the desired length.
Thanks for your help, but now all of the datas in my table will be one line on the out file txt.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.