BookmarkSubscribeRSS Feed
Nasser_DRMCP
Lapis Lazuli | Level 10
data have ;
input category ~ $15. amount ;
datalines ;
REGUL 15
DEPNONDTX3 32
;
run;



%macro mc_export_xls ;

PROC CONTENTS DATA = have
OUT = work.dictionnaire
NOPRINT ;
RUN ;

PROC SQL noprint ;
	SELECT COMPBL(name!!
		CASE
			WHEN (type=1 AND
			format IS MISSING)
			THEN " NUMX12.9 "
		WHEN (type=1) THEN " "!!
		COMPRESS(cats(format,formatL,".",formatD," "))
		ELSE ""
		END)
		,
	QUOTE(LEFT(TRIM(COALESCE(label,name)))),
		COUNT(*),
		MAX(nobs)+1
	INTO : variables SEPARATED BY " '09'x ",
		: en_tete SEPARATED BY " '09'x ",
		: nbVar ,
		: nbObs
	FROM work.dictionnaire
		ORDER BY varnum
	;
Quit;

FILENAME xlData "&RESULT.have.xls";

DATA _NULL_ ;
FILE xlData DROPOVER lrecl=50000  encoding= 'WE8MSWIN1252' ;
SET have ;
PUT &variables ;
run ;
%mend ;


%mc_export_xls ;

Hello,

 

I have a dataset with a characters string column. by exporting the dataset , a character space appaers at the end of the text.

How could I prevent this space ?

thanks in advance for your help

regards

Nasser

1 REPLY 1
data_null__
Jade | Level 19
You can just use the DSD FILE statement option and forget all the rest. Look it up.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 1 reply
  • 302 views
  • 0 likes
  • 2 in conversation