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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 504 views
  • 0 likes
  • 2 in conversation