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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 668 views
  • 0 likes
  • 4 in conversation