BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I am trying to create a data set with 11 rows.

The outcome that I should get is 11 rows but I see that  I get only 9 rows.

What is the solution for such problem please?

 

 Data ssort;
input source $ group $ ;
sortkey = _n_;
cards;
ABC 833
TT 835
RRRRRR	835
ABC	853
ABC	860
ABC 703
TT 703
TT 705
TT 855
TT 100-199
TT 300-399
;
Run;

 

4 REPLIES 4
s_lassen
Meteorite | Level 14

What is the problem? No idea. When I run the program you supplied, I get 11 rows.

 

Unless, of course, that you have options OBS=9.

Ronein
Meteorite | Level 14

I get 9 rows.

Please find the data that I get.

I want to ask what should I add to my code in order to get correct data?

 

ABC 833 1
TT 835 2
"RRRRRR 8" "ABC 853" 3
"ABC 860" ABC 4
TT 703 5
TT 705 6
TT 855 7
TT 100-199 8
TT 300-399 9

ed_sas_member
Meteorite | Level 14

Hi @Ronein 

 

I have added an INFILE statement to specify the delimiter.

I have also replaced the tabulation by a space in line 3 (RRRRRR 835) because in all other cases, the delimiter is a space.

 

Best,

 

Data ssort;
	infile cards dlm=" " truncover;
	input source $ group $;
	sortkey=_n_;
	cards;
ABC 833
TT 835
RRRRRR 835
ABC 853
ABC 860
ABC 703
TT 703
TT 705
TT 855
TT 100-199
TT 300-399
;
Run;
Kurt_Bremser
Super User

Rows 3, 4 & 5 have a tab as delimiter. You can see that when you insert a blank before the "space". The next value then either jumps by n characters (n is your tab setting) or stays in place.

Make sure you have consistent delimiters in datalines, and use an infile statement with dlm='09'x when you want to use tabs.

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