BookmarkSubscribeRSS Feed
David_Billa
Rhodochrosite | Level 12

There is a HTML and Javascript which reads data from SAS dataset and print the values in HTML webpage. I could see that only alphanumeric values are enclosed with double quotes and not the numbers although the datatype of the variable is character.

 

data test;
input batch $;
datalines;
123456
12AB45
1234AB
;
run;

proc print data=test;
run;

Excepted results to show in HTML page: 

"123456","12AB45","1234AB"

 

This may not be the right forum to ask this question but still I want to know if there is something that can be done in SAS to tackle the issue. 

1 REPLY 1
ballardw
Super User

Proc Print in SAS generally does not show any quotes unless you add them as part of the value. So if you have something currently showing quotes it is likely not done by SAS and should be addressed there.

 

If you expect to show quotes with Proc Print then add the quotes, which may mean you need to increase the length of variables as that will take two characters.

data test;
input batch $;
batch=quote(strip(batch));
datalines;
123456
12AB45
1234AB
;
run;

proc print data=test;
run;

Which works because the default length when reading with $ is 8. The Strip function is needed because otherwise the Quote function will include the default blanks at the end of the 8 characters as part of the value and the second quote isn't seen as it would be in a character position past 8.

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
  • 396 views
  • 0 likes
  • 2 in conversation