Hello,
i'm having an issue with the code below:
proc sql;
select trim(leading 'A' from column1) from table;
quit;
Mya I know what I missed? In SAS documentation it seems that my script is correct but it still throws an error.
Hi @iSAS
Do you mean that you want to remove leading 'A's from a character variable? Is that correct?
If so, you can use the following approach:
data have;
col1 = 'AAAtriAtriAA';
col2 = substr(col1,verify(col1,'A'));
run;
Best,
OK, in this case pleas try the code in previous post, using the VERIFY function.
This function returns the position of the first character in a string that is not in any of several other strings.
Best,
I'll try. thank you. may I know why my script isn't working? it's the same in sas documentation
@iSAS wrote:
I'll try. thank you. may I know why my script isn't working? it's the same in sas documentation
Please post a link to the page. It appears that you are using the FedSQL version of Trim and not the basic SAS version of Trim function. You should be either using Proc FEDSQL (instead of Proc Sql) or pass through code to another DBMS (maybe) with the example version..
Unfortunately in some of the help the FedSQL or DS2 functions appear before the base SAS functions and they sometimes behave differently because of the connections to other data systems they are intended to support.
@iSAS wrote:
I'll try. thank you. may I know why my script isn't working? it's the same in sas documentation
Absolutely NOT. Show the "documentation" where you found this "code":
select trim(leading 'A' from column1) from table;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.