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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 408 views
  • 0 likes
  • 2 in conversation