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

I need to assign the below text to a variable X in sas data step.

 

<br>Learn more at <a href= https://www.test.com/preferred-rewards target="_blank"style="text-decoration: underline"> www.test.com/preferred-rewards </a><br>

 

data test;

x=

<br>Learn more at <a href= https://www.bankofamerica.com/preferred-rewards target="_blank"style="text-decoration: underline"> www.bankofamerica.com/preferred-rewards </a><br>

run;

As the above text has several escape quotes etc., I decided that I need help. Any help is appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Just put single quotes around the text, escapes do not matter in this instance:

data test;
x=
'<br>Learn more at <a href= https://www.bankofamerica.com/preferred-rewards target="_blank"style="text-decoration: underline"> www.bankofamerica.com/preferred-rewards </a><br>';
run;

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Just put single quotes around the text, escapes do not matter in this instance:

data test;
x=
'<br>Learn more at <a href= https://www.bankofamerica.com/preferred-rewards target="_blank"style="text-decoration: underline"> www.bankofamerica.com/preferred-rewards </a><br>';
run;
ballardw
Super User

If your data is going to have more than one record you do want to make sure that you declare a length long enough to hold the longest value X can take. If this is the first time you use X it has basically aquired the length of that statment. If you attempt reuse X later to hold another string that is longer it will be truncated.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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