BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I create a data set but the  column area has no values in the data set that was created?

What is wrong?

 

data tbl1;
infile datalines dlm='|';
length name $10 subject $20 score 8 area $10;
input name subject score;
datalines;
John|Math|98|EU
John|English|76|EU
John|Biology|81|EU
John|Physics|69|EU
John|Economics|79|EU
Tony|Math|65|USA
Tony|English|34|USA
Tony|Biology|87|USA
Tony|Physics|56|USA
Tony|Economics|90|USA
Jeff|Math|41|EU
Jeff|English|45|EU
Jeff|Biology|56|EU
Jeff|Physics|78|EU
Jeff|Economics|34|EU
;
run;
2 REPLIES 2
hashman
Ammonite | Level 13

@Ronein;

As @Kurt_Bremser said, you have forgotten AREA in the INPUT statement. 

But if you coded it as an all-inclusive list (_ALL_), you wouldn't have:

data tbl1 ;                                           
  informat name $10. subject $20. score 8. area $10. ;
  input (_all_) (:) ;                                 
  cards ;                                             
John Math      98 EU                                       
John English   76 EU                                    
John Biology   81 EU                                    
John Physics   69 EU                                    
John Economics 79 EU                                  
Tony Math      65 USA                                      
Tony English   34 USA                                   
Tony Biology   87 USA                                   
Tony Physics   56 USA                                   
Tony Economics 90 USA                                 
Jeff Math      41 EU                                       
Jeff English   45 EU                                    
Jeff Biology   56 EU                                    
Jeff Physics   78 EU                                    
Jeff Economics 34 EU                                  
run ;                                                 

Incidentally, you need neither the delimiter nor the INFILE statement with your input since you have no intervening blanks in your raw data. Plus, the proper instrument for reading raw data is INFORMAT rather than LENGTH. In your simple case the latter works, but if you had something more elaborate to read (date or datetime, say) it wouldn't. 

 

Kind regards

Paul D.

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
  • 384 views
  • 0 likes
  • 3 in conversation