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!
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!
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.
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
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!
Thank you so much!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.