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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 412 views
  • 0 likes
  • 3 in conversation