04-25-2018 01:27 PM
I have a line of raw data as follow.
Variables: GenderType Year Total Asofdate
ihe-M 1970 5,044 Retrieved: 03/14/2012 f-IHE 1970 3,537 Retrieved: 03/14/2012
ihe-m 1980 5,874 Retrieved: 03/14/2012 f-IHE 1980 6,223 Retrieved: 03/14/2012
It should have four gendertype but I can only read ihe-M and ihe-m. How to ask SAS to pick up f-IHE and f-IHE.
Even if I put @, it still won't read.
libname Lesson08 '/home/coccus030/sasuser.v94/';
Infile '/home/coccus030/sasuser.v94/institutiondata.txt' firstobs=2;
Input GenderType & $6. Year 7-10 Total comma6. @29 AsofDate mmddyy10.;
04-25-2018 01:52 PM
04-25-2018 01:43 PM
@elsalam You asked the same question in another thread
Kindly do not duplicate the same questions over and over .. Thank you!
04-25-2018 01:49 PM
Did you check the solution in your other post and did you notice double trailing (@@) which is used to hold the line.
04-25-2018 02:01 PM
04-25-2018 01:52 PM
04-25-2018 02:03 PM
I ensure this code will work but I wonder whether or not it has another way.
I use @@ at SAS studio but it never display the result.
It will continuous to run so I click cancel.
04-25-2018 02:09 PM
You can use @@, but you then have to change the INPUT statement. For example, you can't tell SAS to move to column 29 to start reading the date. If you do that, SAS will never get to the end of the line of data (hence you are seeing an infinite loop). You would need to use a style of INPUT that keeps moving from left to right.
Since the format is slightly different on the left vs. the right (two spaces vs. one space separating two of the variables), it's easier to just hard-code all the positions.
04-25-2018 03:16 PM
Do you have any null values represented as spaces only? There are none in your example.
Variables: GenderType Year Total Asofdate ihe-M 1970 5,044 Retrieved: 03/14/2012 f-IHE 1970 3,537 Retrieved: 03/14/2012 ihe-m 1980 5,874 Retrieved: 03/14/2012 f-IHE 1980 6,223 Retrieved: 03/14/2012
If not then just use list mode input. Why not just read the text in the line to its own variable?
data want ; infile 'filename' firstobs=2 truncover ; input GenderType :$10. Year Total :$comma. AsOfType :$12. Asofdate :mmddyy. @@; format Asofdate yymmdd10. ; run;
Need further help from the community? Please ask a new question.