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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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