BookmarkSubscribeRSS Feed
noobs
Fluorite | Level 6

How do I go about creating raw data file in SAS Enterprise Guide?

Later I intend to use INFILE statement and INPUT to access this file and its contents.

Is it even possible to do so?

Regards,

Dhanashreeata

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

Hope this is what you were expecting

data _null_;

    file "E:\source\test.txt" print;

    input name$ age;

    if _n_=1 then put @1 "name" @10 "age";

    put @1 name  @10 age;

cards;

alice 30

william 20

;

run;

Thanks,

Jagadish

Thanks,
Jag
noobs
Fluorite | Level 6

Yes, that is what I am looking for. Although .dat extension. So after I have created that file, I am having following script to access its contents and generate data set:

filename testref "/home/dhanashree.gadka/user/DUG/test.dat";

data work.vegd;

     infile testref;

     input vname $ vfreq $;

run;

I see this error in Log:

ERROR: Invalid logical name.

ERROR: Error in the FILENAME statement.

ERROR: Physical file does not exist, /sso/biconfig/930/Lev1/SASApp/TESTREF.

Am I missing something?

And in theory, what is the best way to peek at raw data files for data examination purposes so that one can figure out what is the data structure and how to write the input statements.

Thanks so much.

ChrisHemedinger
Community Manager

From the log, it looks like you are using a SAS installation that hosted with SAS OnDemand.  Is that correct?  If so, be sure to consult the appropriate guidance for how to access/create external files in this environment.

With SAS Enterprise Guide, you can easily discover the structure of a text-based data file by opening it with File->Import Data.  The Import Data task will generate a DATA step with INPUT statements to read your file structure.

Chris

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Jagadishkatam
Amethyst | Level 16

i believe the code is correct.

Need to check the path. Also please try to give a different filename, instead of testref try testr. Though testref should also work, but since it is throwing an error try to replace the name.

Thanks,

Jagadish

Thanks,
Jag

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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