BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
iyinope
Fluorite | Level 6

Hi, so I am trying to use data step to read in the csv. file. I am looking for options in the INFILE statement and INFORMAT/FORMAT to use to make sure that I create the datasets correctly.

 

I tried to run it but the sex, name and race can out as dots.

I am new to SAS and a quick response would be appreciated. 

Thank you 🙂

@SAS5 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

There is no need to attach files to share TEXT.  Use the Insert Code button in the forum editor window to get a pop-up window where you can paste/edit the text.

ID_NUM,NAME,DOB,Sex,Race,MARITAL,OWNHOME,EDUCATION,EMPLOYED
110126,LLLLLLLL,2/23/1943,1,1,4,2,5,1
110010,AAAAAAAA,3/20/1954,1,3,3,1,7,4
110020,BBBBBBBB,8/1/1948,1,1,3,1,7,1
110031,CCCCCCCC,12/11/1952,1,1,3,1,5,1
110032,DDDDDDDD,8/1/1944,2,2,3,1,7,1
110037,EEEEEEEE,9/26/1968,1,1,3,1,5,1
110068,FFFFFFFF,10/9/1953,2,1,2,1,7,1
110075,GGGGGGGG,8/12/1942,2,1,3,1,7,4
110090,HHHHHHHH,8/7/1959,2,2,5,2,2,4
110098,IIIIIIII,2/16/1970,1,1,6,2,3,1
110120,JJJJJJJJ,11/22/1955,1,2,2,2,3,2
110121,KKKKKKKK,7/10/1946,1,1,3,1,3,1

Your file looks like a normal CSV (comma separated values) file.

You can easily write a DATA step to read such a file.

data want;
   infile 'Personal.csv' dsd truncover firstobs=2;
   input
     ID_NUM :$6.
     NAME :$20.
     DOB :mmddyy. 
     Sex Race MARITAL OWNHOME EDUCATION EMPLOYED
   ;
   format DOB yymmdd10.;
run;

View solution in original post

6 REPLIES 6
andreas_lds
Jade | Level 19

Please post the code you have, so that we can suggest fixes.

ballardw
Super User

SAS, by default, will show a "dot" to represent a missing value for a numeric variable.

Typical causes would be values in the file that are read as numeric values that are not actually numeric such as "N/A" or ">45" or that are missing in the source file. If you see "Invalid data" messages in the log then then your values are not compatible with how you attempt to read the  data. Without details it is extremely hard to make suggestions.

 

Best for debugging your particular problems are to go to the LOG. You can share the log by copying text of the program code you ran along with all the messages and notes. Then on the this forum open a text box using the </> icon that appears above the message window and pasting the copied text.

 

The text box is important because the main message window on this forum will reformat pasted text which can reduce the usefulness of the diagnostic messages SAS often provides for problems with code or data.

 

 

Tom
Super User Tom
Super User

There is no need to attach files to share TEXT.  Use the Insert Code button in the forum editor window to get a pop-up window where you can paste/edit the text.

ID_NUM,NAME,DOB,Sex,Race,MARITAL,OWNHOME,EDUCATION,EMPLOYED
110126,LLLLLLLL,2/23/1943,1,1,4,2,5,1
110010,AAAAAAAA,3/20/1954,1,3,3,1,7,4
110020,BBBBBBBB,8/1/1948,1,1,3,1,7,1
110031,CCCCCCCC,12/11/1952,1,1,3,1,5,1
110032,DDDDDDDD,8/1/1944,2,2,3,1,7,1
110037,EEEEEEEE,9/26/1968,1,1,3,1,5,1
110068,FFFFFFFF,10/9/1953,2,1,2,1,7,1
110075,GGGGGGGG,8/12/1942,2,1,3,1,7,4
110090,HHHHHHHH,8/7/1959,2,2,5,2,2,4
110098,IIIIIIII,2/16/1970,1,1,6,2,3,1
110120,JJJJJJJJ,11/22/1955,1,2,2,2,3,2
110121,KKKKKKKK,7/10/1946,1,1,3,1,3,1

Your file looks like a normal CSV (comma separated values) file.

You can easily write a DATA step to read such a file.

data want;
   infile 'Personal.csv' dsd truncover firstobs=2;
   input
     ID_NUM :$6.
     NAME :$20.
     DOB :mmddyy. 
     Sex Race MARITAL OWNHOME EDUCATION EMPLOYED
   ;
   format DOB yymmdd10.;
run;
iyinope
Fluorite | Level 6
Yes, thank you so much.
Reeza
Super User
FYI - answers we give here likely won't match what you're being taught in courses.
iyinope
Fluorite | Level 6
hmmmmm

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 573 views
  • 1 like
  • 5 in conversation