I need to use length statement ,not use 'informat name $ 16' , the former is correct , and the latter is wrong. I don't know why, just judge it according to the output.
You are right. the length is not enough.
Please try this. You need INFORMATs for your character variables too as they are longer than 8 characters.
data ABC;
infile 'C:\Users\liaodong\Documents\My SAS Files\prep guide\base\practice data\cert\new_hires.csv' dlm = ',' dsd firstobs=2;
informat name $17. company country $30. hire_date date_of_birth mmddyy10.;
format hire_date date_of_birth mmddyy10.;
input name $ hire_date company $ country $ date_of_birth;
run;
That's right, thank you for your help.
wait, the output of your code is wrong .
@tianerhu wrote:
notice : there are no quotation mark around values of the name variable , this is the key point why this question is hard to code .
With a delimited text file the quotes around a name would only be needed if the delimiter was part of the value such as the comma in "Smith, John" . Then the quotes work with the DSD option. The DSD, among other things, says "don't read delimiters within quotes".
Thank you for your help.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.