×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Macro creation while skipping quotes

Macro creation while skipping quotes

Macro creation while skipping quotes

(OP)
I have some SAS macros that need to be created. These macros are used as file descriptions for Excel files. The macros are derived from fields in files that are input to the program. Unfortunately all these fields exist as character fields and I need to strip the leading and trailing quotes from these fields when creating the macro. The field lengths are not known, is there a way to do this?
Example:
%MODEL(CLIENT = 'TECH', REPORT_SEGMENT = 'TOTAL', PRIOR_ANALYSIS_YEAR = 'ANY', SVCDTE1_PRIOR = '2001-01-01', TIME_CODE = 'ANNUAL');
Needs to be converted to
&CLIENT should be TECH not 'TECH' etc.
so when the excel file is created
c:\TEMP\MODEL(&CLIENT.)(&REPORT_SEGMENT.)(&TIME_CODE.).xls it will be without the quotes for the macros.
Thanks,



Michael

RE: Macro creation while skipping quotes

Maybe I am missing something here...
Functions that I know would help:
Index($tring, $part) - returns where $part is within $tring

Left($tring) - left justifies the charactr string

Length($tring) - gives you the length of the string

Translate($tring,$to,$from) - changes all occurances of $from to $to within the input string

Compress($tring,$remove) - takes all occurances of $remove from $tring

Trim($tring) - removes trailing blanks

Verify($tring, $part) - finds the first occurance of $part within $tring

You can even embed these within each other - so Length(trim($string)) or substr($tring, 1, Verify($string, "'")-1)

I have even used the function QUOTE($tring) to have SAS put quotes around the whole string.

If you show me the varaiables that you are using to make the desired output string, I am sure we can figure it out.

RE: Macro creation while skipping quotes

(OP)
Hi, The variable are in my email above.
Example &Client comes in as 'TECH', I would need a new macro called RClient which changes that to TECH.
Thanks,



Michael

RE: Macro creation while skipping quotes

(OP)
I figured it out

%let oldvar = 'tech';
%let newvar = %substr(&oldvar, 2, %length(&oldvar)-2);
%put  &newvar ;

will display
tech



Michael

RE: Macro creation while skipping quotes

too quick --- I did not have the chance to help out --- glad u got it

RE: Macro creation while skipping quotes

Try this:

%let oldvar = 'TECH';
%let newvar = %SYSFUNC(compress(&oldvar, "'"));

%SYSFUNC executes SAS language functions or user-written functions within the macro facility.

RE: Macro creation while skipping quotes

teralearner - I have wanted to do that for YEARS and SAS support said it was not possible --- have a 'star' on me.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close