Hi All,
I've got Maheshvaran's script successfully running but all the the files have some problematic trailing blanks. Looks as though it's totaling 32 characters so if my Table name only has 10 characters there will be 32 blanks.
I'm a little new to SAS so I'm having trouble figuring out how to get rid of the blanks. I assume I could use something a long the lines of myfile=trim(right(Table)) and then do OUTFILE="&myfile..csv" but I don't know how to create this myfile variable in SAS, or if I'm even on the right track.
Any help would be appreciated.
Side effect of using SQL to create the macro variable.
Change this line:
SELECT COMPRESS(MEMNAME) INTO: Table
to
select memname into :table separated by ' '
or add this statement before the PROC EXPORT
%let table=&table ;
Oh wow that was fast!
And either option does the job.
Thanks heaps Tom.
Hi Tom
do you know why the following code to export an entire library of datasets into csv files is not working properly:
I mean when there is a cell with two lines of comments ex: 001 I have a pen.
The pen is on the table.
002 xxxxx
exporting with the command of Guide enterprise tha two lines are exported in the right way leaving 1 line for 1 code 001 I have a pen. The pen is on the table
002 xxxxxx
The almost right code is:
data _null_;
set sashelp.vmember;
where libname eq 'BISCOE';
where also memtype eq 'DATA';
length export $256;
*Insert the path (NO CASE SENSITIVE)with the name given in the server of SAS, below!!;
export = catx(' ','proc export data=',catx('.',libname,memname),'outfile=',quote(cats('f:\accesstopcfiles\enrico\',memname,'.CSV')),' dbms=csv replace;
delimiter=","; run;');
put export;
call execute(strip(export));
run;
Open an new question thread rather than piggy backing onto a discussion from last year.
I can't I am a newbie ...:smileyconfused:
I don't think Hai.Kou's suggestion actually works because the space-delimited string of tables to export was not being scanned to pick out individual datasets. I've added %scan(&a1, &i, ' ').
proc sql ;
select memname into : a1 separated by ' '
from dictionary.tables
where libname='YOURLIBRARY';
quit;
%macro csv;
%do i=1 %to %sysfunc(countw(&a1)) ;
proc export data=YOURLIBRARY.%scan(&a1, &i, ' ')
outfile="c:\temp\%scan(&a1, &i, ' ').csv "
dbms=csv
replace;
run;
%end;
%mend csv;
%csv
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.