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

I ran the following code to import my data and it ran fine:

 

PROC IMPORT DATAFILE="/folders/myfolders/SAS Assignment/Cross Sell_Data.csv"
   OUT=CSD
   DBMS=CSV
   REPLACE;
RUN;
 
Post this step I ran this code but just a blank file got created: 
 
Libname CSD "/folders/myfolders/SAS Assignment";run;
 
I need to further add this code to divide the dataset into Development and Validation dataset which is obviously not working because of a blank data set.
 
Please help me figure out my mistake. thank you!
 
DATA CSD.DEV CSD.VAL;
SET CSD.BITS;
IF RANUNI (1000)<= 0.7 THEN OUTPUT CSD.DEV;
ELSE OUTPUT CSD.VAL;
RUN;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@MeghnaRoy9 wrote:

I ran the following code to import my data and it ran fine:

 

PROC IMPORT DATAFILE="/folders/myfolders/SAS Assignment/Cross Sell_Data.csv"
   OUT=CSD
   DBMS=CSV
   REPLACE;
RUN;
 
Post this step I ran this code but just a blank file got created: 
 
Libname CSD "/folders/myfolders/SAS Assignment";run;

What is a "blank file"? Do you mean that there are no SAS data sets in the folder /folders/myfolders/SAS Assignment? That would be the expected result. THe only thing that a LIBNAME statement does is that it tells SAS to look in the specified folder for SAS data sets, and if there are no SAS data sets in there, it shows that fact. (Also, you don't need a RUN; statement after a LIBNAME statement)

 

Perhaps this is what you want? Note the change of order, and the referring to the imported data set by CSD.cross_sell_data, the name beginning with CSD and a period indicating that this data set is to reside in the SAS library named CSD, which was defined by the LIBNAME statement.

 

libname csd "/folders/myfolder/SAS assignment";

PROC IMPORT DATAFILE="/folders/myfolders/SAS Assignment/Cross Sell_Data.csv"
   OUT=CSD.cross_sell_data
   DBMS=CSV
   REPLACE;
RUN;

Also, please go back to your original post and give a meaningful title to your question, such as "LIBNAME and PROC IMPORT problem".

--
Paige Miller

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

If you do not have a file called

bits.sas7bdat

in your directory

/folders/myfolders/SAS Assignment

Then you won't have a dataset

CSD.BITS

I see no code that would have created this dataset, either.

PaigeMiller
Diamond | Level 26

@MeghnaRoy9 wrote:

I ran the following code to import my data and it ran fine:

 

PROC IMPORT DATAFILE="/folders/myfolders/SAS Assignment/Cross Sell_Data.csv"
   OUT=CSD
   DBMS=CSV
   REPLACE;
RUN;
 
Post this step I ran this code but just a blank file got created: 
 
Libname CSD "/folders/myfolders/SAS Assignment";run;

What is a "blank file"? Do you mean that there are no SAS data sets in the folder /folders/myfolders/SAS Assignment? That would be the expected result. THe only thing that a LIBNAME statement does is that it tells SAS to look in the specified folder for SAS data sets, and if there are no SAS data sets in there, it shows that fact. (Also, you don't need a RUN; statement after a LIBNAME statement)

 

Perhaps this is what you want? Note the change of order, and the referring to the imported data set by CSD.cross_sell_data, the name beginning with CSD and a period indicating that this data set is to reside in the SAS library named CSD, which was defined by the LIBNAME statement.

 

libname csd "/folders/myfolder/SAS assignment";

PROC IMPORT DATAFILE="/folders/myfolders/SAS Assignment/Cross Sell_Data.csv"
   OUT=CSD.cross_sell_data
   DBMS=CSV
   REPLACE;
RUN;

Also, please go back to your original post and give a meaningful title to your question, such as "LIBNAME and PROC IMPORT problem".

--
Paige Miller
MeghnaRoy9
Obsidian | Level 7
Thank You so much! it was really helpful.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 8129 views
  • 1 like
  • 3 in conversation