BookmarkSubscribeRSS Feed
hema_bhure
Calcite | Level 5

Hi All,

 

Thanks in advance. I want to read the country name using following code, but unable to read the third and forth record properly observation properly it  just read the CZECH RE not a full name of country, Please help me to read the observation correctly.

 

data country;
input country $ code $;
datalines;
Astria EUR 
BELGIUM EUR
CZECH_REPUBLIC EUR

united Kingdom GBP
;
run;

 

please help me to read the data properly using datalines.

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You need to indicate that the maximum number of characters in country is 15.

 

Also, you would make your life so much easier if you put a delimiter between country and code. Right now, because the space is the delimiter, there's really not a good way to know that "united" (which is separated by a space from) "kingdom" should be read as "united kingdom". Your program will decide that "united" is the country and "kingdom" is the code.

 

So, if you use a delimiter which is TWO spaces from the end of the country name, then you have data that is more easily read. Note the two spaces in the data between the last letter of country and the first letter of code. (Other delimiters could be chosen as well)

 

data country;
input country & $15. code $;
datalines;
Astria  EUR 
BELGIUM  EUR
CZECH_REPUBLIC  EUR
united Kingdom  GBP
;

 

--
Paige Miller
hema_bhure
Calcite | Level 5
thank you everyone, I am able to read it successfully

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