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

How do I make a small sample raw data (txt) file on my desktop and read it into SAS Studio using a FILENAME statement and the COLUMN INPUT METHOD?

 

For example, this is the raw data file (txt). I named it as joytp and I placed the file on my desktop. I want to read into SAS Studio:

 

2810 61 MOD  F

2804 38 HIGH F

2807 42 LOW  M

2816 26 HIGH M

2833 32 MOD  F

2823 29 HIGH F

 

 

Can anyone tell me the code that I have to write before the below lines inorder to read the txt file above into SAS Studio:

 

input ID $ 1-4 Age 6-7 Actlevel $ 9-12 Sex $ 14;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
You only mention a filename (joytp.txt), but you did not mention whether you put the file in your shared folder location. In order to read the file, you would need to either do this:

INFILE '/folders/myfolders/joytp.txt';
OR

FILENAME mytxt '/folders/myfolders/joytp.txt';

then
INFILE mytxt;
INPUT ..... ..... ;

But, this all hinges on whether you put the .TXT file into your shared folder location. Can you see the file when you are inside SAS Studio? If so, you should be able to right click on the file name, choose Properties and see the path location to use in either your FILENAME or your INFILE statement. The Location information in the Properties window will show you the fully qualified location that you need to just copy and paste into your code.

Of course, if you do not see JOYTP.TXT in your SAS Studio files, then you will need to move it into your shared folder location or a location where you know that SAS University Edition can read. Just remember that SAS University Edition in a Virtual Machine will NOT use C: drive locations.

cynthia

View solution in original post

4 REPLIES 4
Reeza
Super User

Are you using SAS University Edition?

SamuelRajKandru
Quartz | Level 8
Yes, Univ Edition. Thanks.
Cynthia_sas
SAS Super FREQ
Hi:
You only mention a filename (joytp.txt), but you did not mention whether you put the file in your shared folder location. In order to read the file, you would need to either do this:

INFILE '/folders/myfolders/joytp.txt';
OR

FILENAME mytxt '/folders/myfolders/joytp.txt';

then
INFILE mytxt;
INPUT ..... ..... ;

But, this all hinges on whether you put the .TXT file into your shared folder location. Can you see the file when you are inside SAS Studio? If so, you should be able to right click on the file name, choose Properties and see the path location to use in either your FILENAME or your INFILE statement. The Location information in the Properties window will show you the fully qualified location that you need to just copy and paste into your code.

Of course, if you do not see JOYTP.TXT in your SAS Studio files, then you will need to move it into your shared folder location or a location where you know that SAS University Edition can read. Just remember that SAS University Edition in a Virtual Machine will NOT use C: drive locations.

cynthia
SamuelRajKandru
Quartz | Level 8
Ah! Got it, Thank you so much, been struggling with this since an hour. I moved the file to the University Edition shared folder and followed your steps! Thanks!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 2441 views
  • 3 likes
  • 3 in conversation