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

I use SAS 9.4 and am trying to import a file with sas7bdat. I have the file and I've done this before but every time I try to import it, it comes up showing 1 observation and 0 variables. There should be 12 observations and 4 variables. This is what I put in:

 

 

LIBNAME quiz "C:\Users\OneDrive\Desktop\BIST0535";
DATA quiz.sbp_2;
RUN;

 Now sbp_2 has 12 observations and 4 variables, but this is the answer I got out: 

NOTE: The data set QUIZ.SBP_2 has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.03 seconds 

but it's the correct file name and everything and I can't figure out why it is erasing my variables. Please Help!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

If you already ran this, you destroyed your data set and first need to recreate it before proceeding. This means re-downloading the file from where you originally got it or restoring it somehow. 

 

Some concepts for you: 

1. Libname - think of this as a path to your SAS data sets

 

A data step should be as follows:

 

data OutputDataName;
set InputDataName;

run;

Note that since you used the code data quiz.sbp_2 instead of in the SET statement you accidentally overwrote it. So once you actually recreate it you'll be good to go. 

 

libname quiz 'path to folder';

data quiz;
set quiz.sbp_2;
run;

proc print data=quiz;
run;

@nmy15 wrote:

I use SAS 9.4 and am trying to import a file with sas7bdat. I have the file and I've done this before but every time I try to import it, it comes up showing 1 observation and 0 variables. There should be 12 observations and 4 variables. This is what I put in:

 

 

LIBNAME quiz "C:\Users\OneDrive\Desktop\BIST0535";
DATA quiz.sbp_2;
RUN;

 Now sbp_2 has 12 observations and 4 variables, but this is the answer I got out: 

NOTE: The data set QUIZ.SBP_2 has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.03 seconds 

but it's the correct file name and everything and I can't figure out why it is erasing my variables. Please Help!




View solution in original post

4 REPLIES 4
ChrisBrooks
Ammonite | Level 13

If you already have a sas7bdat file then that is already a SAS data set - you don't need to "import" it at all.

 

If you want to copy it to another data set then you need a SET statement; what's happening in your code is that, assuming the original file is called sbp_2 then you're overwriting it with a blank file because of the absence of a SET statement.

r_behata
Barite | Level 11

Hello @nmy15 welcome to the sas community.

 

Please follow the instructions in this video on how to read external files into sas. 

 

https://video.sas.com/detail/video/4573016758001/creating-a-sas-table-from-a-csv-file

 

 

Reeza
Super User

If you already ran this, you destroyed your data set and first need to recreate it before proceeding. This means re-downloading the file from where you originally got it or restoring it somehow. 

 

Some concepts for you: 

1. Libname - think of this as a path to your SAS data sets

 

A data step should be as follows:

 

data OutputDataName;
set InputDataName;

run;

Note that since you used the code data quiz.sbp_2 instead of in the SET statement you accidentally overwrote it. So once you actually recreate it you'll be good to go. 

 

libname quiz 'path to folder';

data quiz;
set quiz.sbp_2;
run;

proc print data=quiz;
run;

@nmy15 wrote:

I use SAS 9.4 and am trying to import a file with sas7bdat. I have the file and I've done this before but every time I try to import it, it comes up showing 1 observation and 0 variables. There should be 12 observations and 4 variables. This is what I put in:

 

 

LIBNAME quiz "C:\Users\OneDrive\Desktop\BIST0535";
DATA quiz.sbp_2;
RUN;

 Now sbp_2 has 12 observations and 4 variables, but this is the answer I got out: 

NOTE: The data set QUIZ.SBP_2 has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.03 seconds 

but it's the correct file name and everything and I can't figure out why it is erasing my variables. Please Help!




nmy15
Calcite | Level 5

Thank you so much! 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1164 views
  • 3 likes
  • 4 in conversation