DATA Step, Macro, Functions and more

Could not Read the below data into the SAS Data Set

Reply
Contributor
Posts: 29

Could not Read the below data into the SAS Data Set

182-04-7814ASPDEN530

302-57-5023ATWOOD480

123-89-8470BROSNAN560

152-64-0014BROSSO780

813-63-7456CUTCHINS790

186-79-3143HOLERBACH670

Thank youSmiley Happy

Contributor SKK
Contributor
Posts: 35

Re: Could not Read the below data into the SAS Data Set


Hi,

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

Super User
Super User
Posts: 7,392

Re: Could not Read the below data into the SAS Data Set

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;

Ask a Question
Discussion stats
  • 2 replies
  • 197 views
  • 0 likes
  • 3 in conversation