How to account for spaces when using INFILE for txt file in SAS? -


i'm importing following data .txt file.

george washington      02/22/1732 12/14/1799 john adams             10/19/1735 07/04/1826 thomas jefferson       04/13/1743 07/04/1826 james madison          03/16/1751 06/28/1836 james monroe           04/28/1758 07/04/1831 andrew jackson         03/15/1767 06/08/1845 john quincy adams      07/11/1767 02/23/1848 william henry harrison 02/09/1773 04/04/1841 

i'm using following code:

 data presidents;      infile "g:\deadpresidents.txt";      input name $23. birth mmddyy10. death mmddyy10.;  run; 

this allows me read in name , birthdate correctly, won't read in date of death, because sas thinks space between 2 dates part of death variable. if change

birth mmddyy10. 

to birth mmddyy11. works fine.

is there way have sas account spaces separate variables in txt file? able use mmddyy10 since that's length of actual date variable.

you move cursor. relative motion

input name $23. birth mmddyy10. +1 death mmddyy10.; 

or absolute

input name $23. @24 birth mmddyy10. @35 death mmddyy10.; 

or if know birth , death neither blanks use modified list mode

input name $23. birth :mmddyy10. death :mmddyy10.; 

note if assign informat variable , use list mode input not need specify width of informat since sas ignore anyway , adjust width uses data on line.

input name $1-23 birth death ; informat birth death mmddyy. ; 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -