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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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