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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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