BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I'm currently using data _null_ file reports to insert dynamic html code.
I'm placing a put statement before each line of code (there are 70 lines of code).
I have two questions:
1) Is there a better way to write html code in SAS than using put statements before each line?
2) How do I fix the quotation marks on the next three lines of code to make it run (the error occurs on the line with mycountainer.innerHTML)? The html code is correct by itself, but when I add the put statements for these last few lines I get an error due to the single quotation marks needed for the put command.

put ' var mycountainer=document.getElementById("cpcontainer")';
put ' mycountainer.innerHTML="Days since last injury:
"+result['days']+" days "+result['hours']+" hours "+result['minutes']+" minutes "+result['seconds']+" seconds"';
put '}';
put '';

Thank you.
1 REPLY 1
Patrick
Opal | Level 21
It's a pain but you will have to quote double quotes with single quotes and single quotes with double quotes. Something like this:

put "xxx 'and this in single quotes' xxx" ' yyy "and this in doubles quotes" yyy';

or this way:
put "xxx 'and this in single quotes' xxx" @;
put 'yyy "and this in doubles quotes" yyy';

As much as I know there is not really an easier way with SAS of creating this kind of html you seem to aim for.
One possibility would be to have your html code in an external file, using tokens for the parts SAS should replace and then using something like:

data _null_;
infile ....;
file ....;
input;
;
put _infile_;
run;

You could also use more than one data step, let's say the first and the last write the header and "footer" section of you html which is normaly static, the middle part writes the dynamic section.

HTH
Patrick

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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