DATA Step, Macro, Functions and more

datalines and macro variable

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

datalines and macro variable

/* Hi , i need some help to create a "dynamic" file with macro variable values , i used the datalines but seems that it is not possible with MACRO */

 

 

 

filename in TEMP;

 

%let val=405;

 

data _null_;

file in;

input;

put _infile_;

datalines;

 

{

"rclcId": &val,

"rclcEndDate": %sysfunc(datetime()),

}

;

run;

 

 

 

 

 


Accepted Solutions
Solution
3 weeks ago
Super User
Posts: 10,209

Re: datalines and macro variable

Macro triggers are not resolved in a datalines block. Use individual put statements instead:

data _null_;
file in;
put;
put "{";
put '"rclcId": '"&val,";
put '"rclcEndDate": '"%sysfunc(datetime()),";
put "}";
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Super User
Super User
Posts: 9,599

Re: datalines and macro variable

Tell us what you have, and what you want.  You can't use macro after the time the macro processor has been through:
macro processor runs

data compiler runs  < - at this point macro will not work.

Occasional Contributor
Posts: 5

Re: datalines and macro variable

for my need ( create a file which is going to be call in a PROC HTTP ( in parameter)  ) , i used the JSON procedure ( i have never used it before ... ) :

 

http://documentation.sas.com/?docsetId=proc&docsetTarget=n0s97o94nhawspn1rjhhsiu4nucz.htm&docsetVers...

 

thanks for your help.

Solution
3 weeks ago
Super User
Posts: 10,209

Re: datalines and macro variable

Macro triggers are not resolved in a datalines block. Use individual put statements instead:

data _null_;
file in;
put;
put "{";
put '"rclcId": '"&val,";
put '"rclcEndDate": '"%sysfunc(datetime()),";
put "}";
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 75 views
  • 1 like
  • 3 in conversation