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

We have a requirement to enclose a variable values in double quotes and output a txt file.
To do that we have used quote function and also quote format. They look fine in the SAS but when we output using proc export its giving the 3 double quotes instead of single double quote before and after the variable value.

We are using the below code as example:
data fr;
set sashelp.cars;
/*format model quote.;*/

model=quote(model);
run;

 

filename test 'path\T1.txt' ;
proc export data = fr
outfile = test
DBMS=tab REPLACE;
run;

 

Expected variable value- "value"
Quote function result -"""value"
Quote format result-"""value"""

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

You're not getting what you think from QUOTE function.  READ THE DOCUMENTATION. 

 

QUOTE quotes the entire value including trailing blanks and when the value is assigned back the variable length is not sufficient.

 

Capture.PNG

View solution in original post

2 REPLIES 2
andreas_lds
Jade | Level 19

Fascinating: proc exports quotes the quotes. Same happens, when using the quote-format in a datastep using file and put to export the data. Using quote + strip seems to create the expected result.

 

data _null_;
   set sashelp.cars;
   file "PATH\T1.txt";
   length Buffer $ 250;

   Buffer = catx('09'x,  Make,  quote(strip(Model)), Type, Origin, DriveTrain, MSRP, Invoice,
      EngineSize, Cylinders, Horsepower, MPG_City, MPG_Highway, Weight, Wheelbase, Length);

   put Buffer;
run;
data_null__
Jade | Level 19

You're not getting what you think from QUOTE function.  READ THE DOCUMENTATION. 

 

QUOTE quotes the entire value including trailing blanks and when the value is assigned back the variable length is not sufficient.

 

Capture.PNG

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
  • 2 replies
  • 1419 views
  • 0 likes
  • 3 in conversation