BookmarkSubscribeRSS Feed
sanjay1
Obsidian | Level 7

Hi Experts,

 


I am tryng to create a link variable by concotinating certain variables. But I am getting blank data.
Please suggest.

 

Below is my data.


Data test;
input number subject$ status$ EMAIL_$ 10.;
datalines;
123 abc yes khgkjh@123
246 bcv no jhhgjh@234
run;

 

/*What I am trying*/
data test1;
set test;
link = "https://Company.abc.def.com/ghi/form/fghfjghkkkkl="||strip(number)||
%nrstr("&Q_subject=")||strip(subject)||%nrstr("&status=")||strip(yes)||%nrstr("&EMAIL_ADDRESS_=")||strip(EMAIL_);
run;

 

Desired output
https://Company.abc.def.com/ghi/form/fghfjghkkkkl=123&Q_subject=abc&status=yes&EMAIL_ADDRESS_=khgkjh...

 

 

Thanks,

Sanjay

4 REPLIES 4
sanjay1
Obsidian | Level 7

Hi Experts,

 


I am tryng to create a link variable by concotinating certain variables. But I am getting blank data.
Please suggest.

 

below is my data


Data test;
input number subject$ status$ EMAIL_$ 10.;
datalines;
123 abc yes khgkjh@123
246 bcv no jhhgjh@234
run;

 

/*What I am tryng*/

data test1;
set test;
link = "https://Company.abc.def.com/ghi/form/fghfjghkkkkl="||strip(number)||
%nrstr("&Q_subject=")||strip(subject)||%nrstr("&status=")||strip(yes)||%nrstr("&EMAIL_ADDRESS_=")||strip(EMAIL_);
run;

 

Desired output
https://Company.abc.def.com/ghi/form/fghfjghkkkkl=123&Q_subject=abc&status=yes&EMAIL_ADDRESS_=khgkjh...

 

Thanks,

Sanjay

 

 

PaigeMiller
Diamond | Level 26

@sanjay1 wrote:

Hi Experts,

 


I am tryng to create a link variable by concotinating certain variables. But I am getting blank data.


Blank data where? In test or in test1 or in your variables? Be specific.

 

To debug these things, it is extremely helpful if you actually look, with your own eyes, at the data sets created, using PROC PRINT or viewtable. Have you actually done that?

 

Are there errors in the SASLOG? Have you tried to figure these out? Can you show us the SASLOG?

 

Also there is no reason to post your question twice. Please help us maintain some order in the forums by not posting questions twice. All replies ought to go into your other thread at https://communities.sas.com/t5/SAS-Programming/Concatenate-multiple-Variables/m-p/509884#M137131  UPDATE: The moderator has combined your two identical questions into one thread.

--
Paige Miller
gamotte
Rhodochrosite | Level 12

Hello,

 

You have written 'yes' instead of 'status'.

 

By using simple quotes to vaoid macrovariables resolution and the cats function, you can make the expression shorter :

 

data test2;
set test;
link = cats("https://Company.abc.def.com/ghi/form/fghfjghkkkkl=",number,'&Q_subject=',subject,'&status=',status,'&EMAIL_ADDRESS_=',EMAIL_);
run;
ballardw
Super User

@sanjay1 wrote:

Hi Experts,

 


I am tryng to create a link variable by concotinating certain variables. But I am getting blank data.
Please suggest.

 

Below is my data.


Data test;
input number subject$ status$ EMAIL_$ 10.;
datalines;
123 abc yes khgkjh@123
246 bcv no jhhgjh@234
run;

 

/*What I am trying*/
data test1;
set test;
link = "https://Company.abc.def.com/ghi/form/fghfjghkkkkl="||strip(number)||
%nrstr("&Q_subject=")||strip(subject)||%nrstr("&status=")||strip(yes)||%nrstr("&EMAIL_ADDRESS_=")||strip(EMAIL_);
run;

 

Desired output
https://Company.abc.def.com/ghi/form/fghfjghkkkkl=123&Q_subject=abc&status=yes&EMAIL_ADDRESS_=khgkjh...

 

 

Thanks,

Sanjay


You have I believe a terrible confusion between Macro functions, macro variable and dataset variables.

Show us what the final result should be for the two lines in the example data.

If you do not use " " around literal text then the &Q do not try to resolve and %nrstr are not needed.

 

You code also fails because you reference a variable YES that does not exist. I believe you meant to use STATUS which sometimes has a value of yes.

 

I am guessing that you want something similar to:

The CATS function strips so there are no leading or trailing spaces

Data test;
   input number subject$ status$ EMAIL_$ 10.;
   length link $ 200.;
   link=cats('https://Company.abc.def.com/ghi/form/fghfjghkkkkl=',number,
'&Q_subject=',subject,'&status=',status,'&EMAIL_ADDRESS_=',EMAIL_);
datalines;
123 abc yes khgkjh@123
246 bcv no jhhgjh@234
run;

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
  • 4 replies
  • 1054 views
  • 0 likes
  • 4 in conversation