BookmarkSubscribeRSS Feed
DannyDsouza
SAS Employee
Hi

facing a weird challenges, in my scenario, I am building an prompted STP which would faciliate the user to enter time, date , which gets pass on to a third party database, which requires me to add " ' " to the value.

The challenge is as follow, due to the value generated by the prompt does not contain value , I am running a data step wherein I am creating a colum with the prompt value and then appending the " ' " to the column value and finally calling call SYMPUT to create a macro variable, Please find enclosd the sample code

%let t1 = 10:30:00;
%let t2 = 15:30:00;
%let tdate = 08Oct2007;

data sasinput.abc;
a = "&t1";
a1="'"|| a || "'";
call symput('time1',a1);
%put &time1;

b = "&t2";
*b1="'"|| b || "'";
call symput("time2",b);
%put &time2;

d = "&tdate";
*d1="'"|| d || "'";
call symput("date1",d);
%put &date1;

run;

This code runs fine in base sas , but if tried to run in STP , it does not resolve the macro variable created via SYMPUT Message was edited by: Danny Dsouza
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Your macro coding (%PUT statements) are co-mingled within your defined SAS DATA step, which has a CALL SYMPUT -- these coding techniques will not generate the results you might expect.

Also, it's unclear whether you are generating some SAS ERROR/WARNING or that the resulting variable value is blank -- suggest you try hardcoding some value to attempt to pass the data on to the STP to test various options, just to ensure your code is functioning at all.

And, here is some useful reading on macro variable SCOPE (local versus global) within the SAS macro language.


Scott Barry
SBBWorks, Inc.

Scopes of Macro Variables
Special Cases of Scope with the CALL SYMPUT Routine
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/tw3514-symput.htm


Scopes of Macro Variables
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002047080.htm

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
  • 1 reply
  • 680 views
  • 0 likes
  • 2 in conversation