BookmarkSubscribeRSS Feed
jackthecat
Calcite | Level 5

Hi all, my second question...

 

I use the query wizard to query data rather then command line type programming.

 

I'm afraid I don't know what SAS EG version it is... it's not on my PC, it is a remote instance that I access via an online method. It is quite a restrictive set up, but it's the only way I can access this data.

 

One of the fields I want to include in my query is populated with a 5 char string (for example AA123, AA124, AA125 etc). However, if I pull it in as is, the query result is way too big, and all I actually need is the first two characters of the code.

 

In sql it would be

select substring(Hcode,1,2) as H_summary... if that clarifies?

 

I can't work out how to do it though.

 

Any help gratefully received.

2 REPLIES 2
BrunoMueller
SAS Super FREQ

Hi

 

Just use the query builder in SAS Enterprise Guide and add a computed column like below, then you can add other columns and use summarization functions on it.

 

Snap3.png

 

The expression for the new column would be SUBSTR(yourColumn, start, length)

jackthecat
Calcite | Level 5

perfect, thanks!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 2 replies
  • 2208 views
  • 0 likes
  • 2 in conversation