Opening up a SAS data file

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

Opening up a SAS data file

I am trying to view this downloaded SAS data file. However, I am having problems with opening it. I try to open 'new program' within SAS and the file will show up if I press show all files. However, when it comes up it is just all characters.(Like shown in the attached picture.) Then I can see it in the given folder when I  search for it on my PC through the explorer (SAS enviorment) but when I try to open it then, it says the file does not exist or cant be displayed.

 

I have attached the pictures and the file itself. I have been stuck on this for a while. Thank YOU! 


Accepted Solutions
Solution
‎09-26-2017 11:43 PM
Trusted Advisor
Posts: 1,615

Re: Opening up a SAS data file

If you can view the table than you can also see the variable names and their attributes, or

you can use PROC CONTENTS to see that information.

 

Then use:

data new;
  set <libname>.<dataset name>;
       ... any sas code relating to variable ...
run;

/* === OR === */
proc print data=<libname>.<dataset name>;
    ... any print options or none ...
run;

View solution in original post


All Replies
Occasional Contributor
Posts: 15

Re: Opening up a SAS data file

Trusted Advisor
Posts: 1,615

Re: Opening up a SAS data file

Sas dataset is a binary file with sas specific format, depending on sas varsion.

A sas program is a text file.

You cannot display sas dataset using sas program edotor.

 

You got the message "The table SASDATA.nhanes2006 either does npt exist or cannot be displayed".

As file is displayed in the library, on the left side window - it exists - but it cannot be displayed.

There might be different reasons for it:

- Is file on same computer as SAS installation? Link to library shows: "\\client\e$\SASData".

  It seems to me that answer is NO.

     -  Do you have permission to read the file?

     -  Is CLIENT and your PC holding same OS? 

        If different OS (like linux and windows) the sas datasets are of different format and you might need 

        use PROC CPORT on client and PROC CIMPORT on your PC or use SAS CONNECT.

     -  Was the sas dataset created in same sas version as you use on your PC ?

    - Maybe the file is corrupted ?

 

What OS you use and in what OS was the sas dataset created ?

What sas version are you using? and with what sas varsion was the sas dataset created ?

  

Occasional Contributor
Posts: 15

Re: Opening up a SAS data file

thanks for the response. So I have managed to be able to view it in the table. Everything seems great. Now my question is how do I use it to code? I beleive I use libname and set statement. But how would that look? 

 

 

Thanks

Solution
‎09-26-2017 11:43 PM
Trusted Advisor
Posts: 1,615

Re: Opening up a SAS data file

If you can view the table than you can also see the variable names and their attributes, or

you can use PROC CONTENTS to see that information.

 

Then use:

data new;
  set <libname>.<dataset name>;
       ... any sas code relating to variable ...
run;

/* === OR === */
proc print data=<libname>.<dataset name>;
    ... any print options or none ...
run;
Occasional Contributor
Posts: 15

Re: Opening up a SAS data file

Awesome! Thank you! This helps a lot!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 126 views
  • 0 likes
  • 2 in conversation