BookmarkSubscribeRSS Feed
tcg15d0
Calcite | Level 5

I have imported a TXT file into my sas document that does not have any variable names and is being run as one column instead of 3. Please help, I'm lost

2 REPLIES 2
ChrisBrooks
Ammonite | Level 13

Can you post a sample of the input data and show us how you tried to import it e.g. code or via a wizard.

ballardw
Super User

How do you know it is supposed to be three variables? Did you tell the method you used that information?

 

If you know because there is a delimiter such as a comma between each variable then your import method needs to be told to separate values with a comma. If you know that the values are in fixed columns then you need that information somewhere in the process.

 

If the data is not sensitive you might paste a few example lines into a codebox opened using the forum {i} menu icon. I suggest the codebox as the main message windows will reformat certain text elements and the pasted data may not be reliable for diagnosing the problem.

 

If your file has no column headers to use as variable names, or you don't like the ones used the SAS Proc Datasets can modify existing names, labels or formats for the variables. The code would look something like:

proc datasets library=work nolist nodetails;
    modify have;
     rename  
      var1=MyNameForVar1
      var2=MyNameForVar2
      var3=MyNameForVar3
     ;
quit;

the library would be the one that you placed the data set in, use your data set in place of Have in the above code, and change the old variable names var1 var2 var3 to the new ones using the pattern above.

 

Note that Proc datasets is one of the few procs that use Quit to end the proc because it can run in interactive mod and each modify or other action can be submitted individually when using interactive mode.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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