BookmarkSubscribeRSS Feed
weather4d
Calcite | Level 5

 

I'm attempting to reorganize some code and start utilizing GitLab for my organization. My plan is to commit our code base with following structure

 

directory/[Main]

  • etl.egp
  • build.egp
  • validation.egp
  • parameters.sas
  • [build-programs]
  • [build-inputs]
  • [etl-programs]
  • [validation-programs]

within build.egp I run parameters.sas with an %include statement:

 

	data _null_;
	name = dequote(&_clientprojectpath);
	cutofflen = length(&_ClientProjectNAME)+3;
	namelen = length(name);
	path = cats('\\company.com\Shares\Projects',substr(name,3,namelen-cutofflen));  *starts string after X: with sas filepath type and drops project name;
	path2 = substr(path,1,length(path)-5); *drops \Main path;
	param_CodeRef = cat(trim(path),"\parameters-0622.sas");
	call symput('param_code', param_CodeRef);
	call symput('egp_location',path);
	call symput('base_directory',path2);
	run;

%include "&param_code.";
*snippet of related code from parameters.sas file
	%let dir_build = &base_directory.\Production\&yyyy.\&mm.\Build;
	%let dir_prep = &dir_build.\Source;

 

 

The problem is that the variable has a line split (enter key) causing the %let statement to create multiple records in macro variable value viewer, neither of them usable.

e.g.

%put &dir_prep.;

output;

"&base_directory. [actual directory does output]

\Production\2022\06\Build"

 

I think my near term problem is solved if I can create %let statements with &base_directory. and no enter keys.

 

possible causes of problem:

  • Line insert in macro variable declared in _null_ data step
  • relative file references under project properties, (speculation that it's truncating path relative to file location).
  • file paths are pretty long (directory =127 char)
5 REPLIES 5
weather4d
Calcite | Level 5
Is call symput likely the cause of the line break? not sure what my options are, I'd prefer to declare these directories with %let statments instead of additional variables in a _null_ dataset. Thanks!
PaigeMiller
Diamond | Level 26

Turn on macro debugging options

 

option mprint symbolgen;

 

Then run this segment of code again and the show us the entire log for this section of code. Copy the log as text and paste it into the window that appears when you click on the </> icon. DO NOT SKIP THIS STEP.

Insert Log Icon in SAS Communities.png

 

 

SYMPUT does not add in characters.

 

--
Paige Miller
weather4d
Calcite | Level 5
I just figured it out. Needed to use %trim instead of trim on the macro variable.
Sorry for confusion - was being overly conservative with what I shared.
ballardw
Super User

Since your &base_directory macro variable is built using the PATH2 variable in that data _null_ you might consider 1) making an actual output data set so you can examine the values created for PATH2 without any macro involvement and 2) test for the presence of odd characters at the end and remove them if needed before creating the macro variable.

 

OR consider supplying the values of the macro variables &_clientprojectpath and &_ClientProjectNAME  used in that data step so we can test them.

You may want to look for copy-and-paste issues where one or both of those macro variables are assigned.

Kurt_Bremser
Super User

This

name = dequote(&_clientprojectpath);

cannot work, as &_clientprojectpath will not contain a valid SAS variable name. Enclose the macro variable reference in quotes.

Maxim 2: Read the Log.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1922 views
  • 0 likes
  • 4 in conversation