BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ajulio4
Obsidian | Level 7

Hello,

I have problem on Viya with something i want to do. Can someone tell mi if its posible and then tell me how i can do it.

am filling my html table with my data.

 

i have this for example : 

data _null_;
file _webout;
set inputData;
put '<tr>';

put '<td class="tabledit-view-mode" style="cursor: pointer;">';
put '<span>' Name;
put '</span>';
put '</td>';



put '<td class="tabledit-view-mode" style="cursor: pointer;">';
put '<span >' ??????????????;
put '</span>';
put '</td>';



put '<tr>';

run;

 

My problem is intead of putting ???? i want to put a variable which is too long and i have to display this variable in this way

		n=0;
	   do until(n>=countw("columnVar",","));
		  grp = scan("columnVar",n);
		  put grp;
	      n+1;
	   end;

am lookin for a way to display my variable in the html <td> and </td>

1 ACCEPTED SOLUTION

Accepted Solutions
SASJedi
SAS Super FREQ

If you want the individual items to display on a new line inside an HTML column, you need to replace the commas (.) with a line break code (<br>). The TRANWRD function can help:

data _null_;
	length text $32767;
	file _webout;
	set inputData;
/* Change all commas to line break tags */ columnVar=tranwrd(columnVar,',','<br>'); put '<tr>'; put '<td class="tabledit-view-mode" style="cursor: pointer;">'; put '<span>' Name; put '</span>'; put '</td>'; put '<td class="tabledit-view-mode" style="cursor: pointer;">'; put '<span >' text; put '</span>'; put '</td>'; run;

 

 

Check out my Jedi SAS Tricks for SAS Users

View solution in original post

4 REPLIES 4
SASJedi
SAS Super FREQ

Max character variable length in SAS is 32,767. Because you are writing an HTML table to the output file, when the file renders in a browser, the text it contains should automatically wrap within the table column for each row. So I'm having difficulty visualizing what you are trying to accomplish with the DO loop. Can you explain a bit more?

Check out my Jedi SAS Tricks for SAS Users
ajulio4
Obsidian | Level 7
for example my variable is this form 
%let var =
 ABCD_GROUP,OPEGROU,AWSAMZ,HOMJACGFF,YEDD_DE,UEUEDD,HDHDHD_GGGGG,OPERATOR_DATA,INVOICE_MKG,GRFSDD_MKT,OFFICE_DIREC,AMZ_RECRUIT,ALL_EVENT,REZO_SAS,AHAHEHEHDH_TERR ;
and in the Html <td> i want this variaable to be display this way :
intead of list form separed by comma :
ABCD_GROUP OPEGROU AWSAMZ
AWSAMZ HOMJACGFF YEDD_DE 
UEUEDD HDHDHD_GGGGG OPERATOR_DATA
INVOICE_MKG GRFSDD_MKT OFFICE_DIREC
AMZ_RECRUIT ALL_EVENT REZO_SAS
AHAHEHEHDH_TERR
SASJedi
SAS Super FREQ

If you want the individual items to display on a new line inside an HTML column, you need to replace the commas (.) with a line break code (<br>). The TRANWRD function can help:

data _null_;
	length text $32767;
	file _webout;
	set inputData;
/* Change all commas to line break tags */ columnVar=tranwrd(columnVar,',','<br>'); put '<tr>'; put '<td class="tabledit-view-mode" style="cursor: pointer;">'; put '<span>' Name; put '</span>'; put '</td>'; put '<td class="tabledit-view-mode" style="cursor: pointer;">'; put '<span >' text; put '</span>'; put '</td>'; run;

 

 

Check out my Jedi SAS Tricks for SAS Users
ajulio4
Obsidian | Level 7

Ok.. Thks so much

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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