I want to remove the trailing spaces on variable inside the macro, i have tried TRIM, STRIP, %LET nothing is working. Can I get help on this please?
%MACRO DRY(count);
data _NULL_;
inpcount = "&count";
baseref1 = substr(jobid,4,2); ------ value of the jobid is 75412
if inpcount < 10 then do;
baseref = baseref2 || inpcount ;
end;
else do;
baseref = baseref2 || inpcount ;
end;
call symputx('baseref',baseref,'g');
run;
%put baseref: &baseref;
--- I am getting the value as "SYMBOLGEN: Macro variable BASEREF
resolves to 38 1
baseref: 38 01"
Expected result should be baseref: 3801
There is nothing wrong with your MACRO variable.
The mistake is in the SAS code the macro generates, your use of the ||
operator. Use the cats()
function instead.
baseref = cats(baseref2,inpcount) ;
Also you need to decide if INPCOUNT should be a character variable or a numeric variable.
You create it as character.
inpcount = "&count";
But then compare it to a number.
if inpcount < 10 then do;
If you want to convert a number to a string with leading zeros use the Z format. For example to always generate two digits even when the number INPCOUNT is less than 10 use the Z2. format.
baseref = cats(baseref2,put(inpcount,z2.)) ;