BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sathish_jammy
Lapis Lazuli | Level 10

 

 

data example2;
infile cards delimiter = ' ' dsd;
length Name $30;
input Name$ ID Score;
cards;
Deepanshu Bhalla 22 987
AttaPat 217 564
Xonxiangnam Samnuelnarayan 33 544
;
proc print noobs;
run;

 

 

SAS Output

Name ID Score
Deepanshu Bhalla 22 987..

 

Even if i use 

length Name :$30; (the same partial O/P occur)

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You can't directly.  What you have here is bad data.  The reason it is bad is because the variables contain the "delimiter", which means there is no logical way to identify where a variable starts and where it finishes, hence it is bad data.  

This illustrates good data, where the delimiter is distinct:

data example2;
  infile cards delimiter=',' dsd;
  length Name $30;
  input Name$ ID Score;
cards;
Deepanshu Bhalla,22,987
AttaPat,217,564
Xonxiangnam Samnuelnarayan,33,544
;
run;

Personally I would send the data back with a fail note, and how to correct it.  Otherwise you will need to read in the data as text, then write some text parse statements to split it up as you want. 

 

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You can't directly.  What you have here is bad data.  The reason it is bad is because the variables contain the "delimiter", which means there is no logical way to identify where a variable starts and where it finishes, hence it is bad data.  

This illustrates good data, where the delimiter is distinct:

data example2;
  infile cards delimiter=',' dsd;
  length Name $30;
  input Name$ ID Score;
cards;
Deepanshu Bhalla,22,987
AttaPat,217,564
Xonxiangnam Samnuelnarayan,33,544
;
run;

Personally I would send the data back with a fail note, and how to correct it.  Otherwise you will need to read in the data as text, then write some text parse statements to split it up as you want. 

 

novinosrin
Tourmaline | Level 20

@Sathish_jammy  you can certainly make SAS read your data as is without touching your values but of course data is a bad data regardless. 

novinosrin
Tourmaline | Level 20
data example2;
infile cards delimiter = ' ' ;
input @;
length Name $30;
Name=substr(_infile_,1, anydigit(_infile_)-1);
input @(anydigit(_infile_)) ID score;
cards;
Deepanshu Bhalla 22 987
AttaPat 217 564
Xonxiangnam Samnuelnarayan 33 544
;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1073 views
  • 2 likes
  • 3 in conversation