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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 766 views
  • 0 likes
  • 4 in conversation