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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.