DATA Step, Macro, Functions and more

Assign the text to a variable

Accepted Solution Solved
Reply
New Contributor Yen
New Contributor
Posts: 4
Accepted Solution

Assign the text to a variable

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.


Accepted Solutions
Solution
‎03-30-2016 10:25 AM
Super User
Super User
Posts: 7,404

Re: Assign the text to a variable

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


All Replies
Solution
‎03-30-2016 10:25 AM
Super User
Super User
Posts: 7,404

Re: Assign the text to a variable

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;
Super User
Posts: 10,500

Re: Assign the text to a variable

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 224 views
  • 0 likes
  • 3 in conversation