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

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.

Tom
Super User Tom
Super User

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 ;

N311V
Calcite | Level 5

Oh wow that was fast!

And either option does the job.

Thanks heaps Tom.

EnricoB
Calcite | Level 5

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;

Tom
Super User Tom
Super User

Open an new question thread rather than piggy backing onto a discussion from last year.

EnricoB
Calcite | Level 5

I can't I am a newbie ...:smileyconfused:

kbk
Fluorite | Level 6 kbk
Fluorite | Level 6

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

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
  • 21 replies
  • 21307 views
  • 4 likes
  • 10 in conversation