BookmarkSubscribeRSS Feed
Chikku
Calcite | Level 5

182-04-7814ASPDEN530

302-57-5023ATWOOD480

123-89-8470BROSNAN560

152-64-0014BROSSO780

813-63-7456CUTCHINS790

186-79-3143HOLERBACH670

Thank you:)

2 REPLIES 2
SKK
Calcite | Level 5 SKK
Calcite | Level 5


Hi,

Do you want the entire value in single variable ???

RW9
Diamond | Level 26 RW9
Diamond | Level 26

That's straightforward:

data want;

     attrib var1 format=$200.;

     infile datalines;

     input var1 $;

datalines;

182-04-7814ASPDEN530

302-57-5023ATWOOD480

123-89-8470BROSNAN560

152-64-0014BROSSO780

813-63-7456CUTCHINS790

186-79-3143HOLERBACH670

;

run;

Though I presume you mean you want to read it in as separate variables?  If so post process it, here is a quick example, you just need to do substrings and chop it up (or use perl regular expressions).

data want;

  set want;

  attrib first_string second_string format=$20. lastnum format=best.;

  first_string=substr(var1,1,10);

  lastnum=input(reverse(substr(reverse(strip(var1)),1,3)),best.);

  second_string=substr(var1,11,length(strip(var1))-3);

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
  • 756 views
  • 0 likes
  • 3 in conversation