BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GreggB
Pyrite | Level 9

what delimiter should I use for importing this .txt file?  Here is the first obs:

 

SCSchool District of*******         W******* High     007

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Since you have an infile and input statements to read then it should be relatively easy to use a file statement that looks similar to the infilr and turn

   input State $1-2 District $3-20 DistNum $21-35 SchName $36-53 ...

into

   put @1 State @3 District @21 Distnum @21 Distnum @36 SchName ....;

 

The @n tells SAS to put the variable starting at that column. Assuming you haven't done anything to drastically change lengths of the values then you shouldn't have any problem.

 

View solution in original post

3 REPLIES 3
Shmuel
Garnet | Level 18

The input line you demostarted seems to be without a deleimiter.

Maybe the variables are fixed length. If it is - you need know at what position each variable starts.

GreggB
Pyrite | Level 9

Good point. Actually, it is fixed width now that I think about it. I have a data file layout that I used to read it in using an INFILE statement.  (see a portion below) Essentially, my task is this: I need to output the file I cleaned up so that it matches the original dirty file. If it doesn't match it, I can't import the results to our data warehouse.  Maybe I need to rethink my whole strategy here.

 

 

data access;
infile "G:\Departments\Research\test scores\ACCESS\&yr.\raw\SC3701_Summative_Stud_File.txt"
lrecl=32767 dsd missover;
input State $1-2 District $3-20 DistNum $21-35 SchName $36-53 ....;

ballardw
Super User

Since you have an infile and input statements to read then it should be relatively easy to use a file statement that looks similar to the infilr and turn

   input State $1-2 District $3-20 DistNum $21-35 SchName $36-53 ...

into

   put @1 State @3 District @21 Distnum @21 Distnum @36 SchName ....;

 

The @n tells SAS to put the variable starting at that column. Assuming you haven't done anything to drastically change lengths of the values then you shouldn't have any problem.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 796 views
  • 1 like
  • 3 in conversation