DATA Step, Macro, Functions and more

compress worksheet name

Reply
Super Contributor
Posts: 647

compress worksheet name

The worksheet name (which is &dat passed as parameter) has spaces in them. I used compress function in the data step to compress the spaces.But it doesnt seem to work and throws an error ,because sas will not support spaces in the dataset name.
any work around for this?
%macro import_caremark(dat);
PROC IMPORT OUT= &dat
DATAFILE= "&inpt.\MPB 2009 08 revised.xls"
DBMS=EXCEL REPLACE;
range"&dat$A3:M32";
GETNAMES=YES;
MIXED=yes;
SCANTEXT=YES;
USEDATE=no;
SCANTIME=YES;


RUN;
data %sysfunc(compress(&dat));
set %sysfunc(compress(&dat));
file_date=put(intnx('month',date(),-1),YYMMD7.);
run;
%mend;
%import_caremark(MPB Sales Report August09);
Super Contributor
Super Contributor
Posts: 3,174

Re: compress worksheet name

Code a %LET statement before the PROC IMPORT to perform the compress on your &DAT variable.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 1 reply
  • 113 views
  • 0 likes
  • 2 in conversation