BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Reeza
Super User
What happens if you specify an informat for your character variables instead of using a LENGTH statement.

tianerhu
Pyrite | Level 9

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.

tianerhu
Pyrite | Level 9

You are right. the length is not enough.

SASKiwi
PROC Star

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;
tianerhu
Pyrite | Level 9

That's right, thank you for your help.

tianerhu
Pyrite | Level 9

wait, the output of your code is wrong .

ballardw
Super User

@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".

tianerhu
Pyrite | Level 9

Thank you for your help.

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
  • 22 replies
  • 3238 views
  • 0 likes
  • 4 in conversation