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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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