BookmarkSubscribeRSS Feed
imdickson
Quartz | Level 8

Hi Guys,

 

With the guides and helps from fellow members here, i now can have data from dictionary in dataset by using this code:

data want;
  set sashelp.vcolumn (where=(libname="CDSSTG"));

run;

 

However, i want to remove the first 5 character from this column called memname and also remove the last character.

I did read up some guides for substr but if i want to apply it for the entire column in a dataset, may i know if i need to use loop?

proc content substrs.PNG

 

Need your guide.

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Like:

data want;
  set sashelp.vcolumn (where=(libname="CDSSTG"));
  memname=substr(memname,6,lengthn(tmp)-6);
run;

 

Ksharp
Super User

plz post it as text not picture, I don't want type it by hand. 

And don't forget to post the output .

 

data _null_;
x='CSTG_XXXXX_ARERT';
y=prxchange('s/^[a-z]+_|[a-z]$//i',-1,strip(x));
put x= y=;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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