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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 820 views
  • 0 likes
  • 4 in conversation