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

LIBNAME samp2 BASE "E:\Sachin\FirstRpt\Library";

data samp2.sample;
infile datalines dlm=' ' dsd ;
input country_name$ diaseases$ death ;
datalines;
India Cancer 200
India TB 300
Pakistan Cancer 200
Pakistan TB 400
united state of america TB 300
united state of america Cancer 4000
;
run;


proc print data=samp2.sample;
run;

 

 

 

Output :-

 

country_
Obs name diaseases death

1 India Cancer 200
2 India TB 300
3 Pakistan Cancer 200
4 Pakistan TB 400
5 united state .
6 united state .

 

 

How to fix this issue as data for USA is not coming correctly.

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

Hi @MG18,

 

If you have embedded blanks then use "&" modifier to read the data. Make sure that when you have embedded blanks in one variable then you have double blanks for the next variables to separate them.

 

For eg: On 1st record between India and Cancer there are two blanks.

 

data sample;
infile datalines dlm=' ' dsd ;
input country_name & $25. diaseases $ death ;
datalines;
India  Cancer 200
India  TB 300
Pakistan  Cancer 200
Pakistan  TB 400
united state of america  TB 300
united state of america  Cancer 4000
;
run;
Thanks,
Suryakiran

View solution in original post

3 REPLIES 3
gamotte
Rhodochrosite | Level 12

Hello,

 

You use space as a the delimter. Strings can thus not contain any space

or they will be interpreted as columns separators.

Use another delimiter.

SuryaKiran
Meteorite | Level 14

Hi @MG18,

 

If you have embedded blanks then use "&" modifier to read the data. Make sure that when you have embedded blanks in one variable then you have double blanks for the next variables to separate them.

 

For eg: On 1st record between India and Cancer there are two blanks.

 

data sample;
infile datalines dlm=' ' dsd ;
input country_name & $25. diaseases $ death ;
datalines;
India  Cancer 200
India  TB 300
Pakistan  Cancer 200
Pakistan  TB 400
united state of america  TB 300
united state of america  Cancer 4000
;
run;
Thanks,
Suryakiran

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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