BookmarkSubscribeRSS Feed
iSAS
Quartz | Level 8

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.

6 REPLIES 6
ed_sas_member
Meteorite | Level 14

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,

iSAS
Quartz | Level 8
yes
ed_sas_member
Meteorite | Level 14

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,

iSAS
Quartz | Level 8

I'll try. thank you. may I know why my script isn't working? it's the same in sas documentation

ballardw
Super User

@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.

 

 

 

Kurt_Bremser
Super User

@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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 6 replies
  • 1514 views
  • 1 like
  • 4 in conversation