BookmarkSubscribeRSS Feed
Lando_Griffen
Calcite | Level 5
In excel is a feature to extract a requested number of characters (left or right) of a column into a new column.
ie, if column a1 had 9009125439
the formula would look like
=right(a1,5)
which would give a result of 25439.
according to what I saw the RIGHT/LEFT function in eg only realigns the column.
I need to know how/if the right/left excel function can be done in eg. Thanks
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Also investigate SUBSTR with the PUT function. If your variable is CHARACTER, then you won't need the PUT function. If your variable is numeric, and large, then you might want to use an explicit PUT function so you can control how the number is converted from numeric to character. SUBSTR only works on character variables.

cynthia
Lando_Griffen
Calcite | Level 5
Thanks. You can probably tell I'm new at this. I appreciate your help.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Here are a couple of examples, one using SUBSTR and LENGTH functions, and the second approach using SUBSTR with REVERSE.

Scott Barry
SBBWorks, Inc.


data _null_;
retain x 'aaabbb ';
y = substr(x,length(x)-2,3);
z = reverse(substr(reverse(trim(x)),1,3));
putlog _all_;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1065 views
  • 0 likes
  • 4 in conversation