DATA Step, Macro, Functions and more

Call Symput query

SAS Employee
Posts: 8

Call Symput query


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;

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;


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
Super Contributor
Super Contributor
Posts: 3,176

Re: Call Symput query

Posted in reply to DannyDsouza
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

Scopes of Macro Variables
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation