BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
glee217
Calcite | Level 5
*Set up title on line 1;
TITLE1 "STATS 301(glee217/749750841): &sysuserid";
*Specify SAS library for storing permanent SAS datasets;
LIBNAME stats301 "H:\stats301\A2";

proc import out=Work.Pumpkin1
datafile="H:\stats301\A2\Pumpkin.txt"
DBMS=tab REPLACE;
getnames=no;
datarow=1;
run;

i imported the data by using the SAS code above,

 

 

and next i wanted to rename variables but it only gave one variable for the "first_name".

(Here is the code for renaming variables)

**renaming variables;
data Work.Pumpkin1;
set work.Pumpkin1;
rename var1=first_name
var2=last_name
var3=age
var4=category
var5=date
var6=judge1
var7=judge2
var8=judge3
var9=judge4
var10=judge5;
run;


 

 

And the error is saying:


WARNING: The variable var2 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable var3 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable var4 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable var5 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable var6 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable var7 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable var8 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable var9 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable var10 in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 7 observations read from the data set WORK.PUMPKIN1.
NOTE: The data set WORK.PUMPKIN1 has 7 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

how can i fix this problem? i would attach the file for my output too.

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

As said already and looking at your text file - it is not tab delimited buy comma delimited.

When you define DBMS=TAB the whole row enters one variable.

 

Change your code t, from

proc import out=Work.Pumpkin1
datafile="H:\stats301\A2\Pumpkin.txt"
DBMS=tab REPLACE;
getnames=no;
datarow=1;
run;

into:

proc import out=Work.Pumpkin1
datafile="H:\stats301\A2\Pumpkin.txt"
DBMS=dlm REPLACE;
Delimiter = ',';
getnames=no;
datarow=1;
run;

 

View solution in original post

7 REPLIES 7
SuzanneDorinski
Lapis Lazuli | Level 10

Look at the note from the log:

 

NOTE: The data set WORK.PUMPKIN1 has 7 observations and 1 variables.

 

There's only one variable in the data set, probably var1. 

glee217
Calcite | Level 5

Oh there must be something wrong in my code!

This is original txt file. And i need to create different variables,

which represent first name, last name, age, category, date, scores from 5 different judges.

 

Would you kindly help me out for this :/?

Tom
Super User Tom
Super User

Your text file appears to be comma delimited, not tab delimited.

To read such a somple text file just define your variables. Attach any required INFORMATs or FORMATs. And then read the variable in.

data pumpkin;
  infile 'pumpkin.txt' dsd truncover ;
  length first_name last_name $40 age 8  category $8 date judge1-judge5 8;
  informat date mmddyy. ;
  format date yymmdd10. ;
  input first_name -- judge5 ;
run;

I prefer to display dates in YMD order to avoid the confusion that using either MDY or DMY order can cause. 

Tom
Super User Tom
Super User

You cannot rename variables that do not exist. Most likely your file is NOT tab delimited. 

 

But why are you using PROC IMPORT if you already know what is in the file?  Just read the file directly.

 

glee217
Calcite | Level 5
Oh there must be something wrong in my code!
This is original txt file. And i need to create different variables,
which represent first name, last name, age, category, date, scores from 5 different judges.

Would you kindly help me out for this :/?
i attached txt file on my different comment.
Shmuel
Garnet | Level 18

As said already and looking at your text file - it is not tab delimited buy comma delimited.

When you define DBMS=TAB the whole row enters one variable.

 

Change your code t, from

proc import out=Work.Pumpkin1
datafile="H:\stats301\A2\Pumpkin.txt"
DBMS=tab REPLACE;
getnames=no;
datarow=1;
run;

into:

proc import out=Work.Pumpkin1
datafile="H:\stats301\A2\Pumpkin.txt"
DBMS=dlm REPLACE;
Delimiter = ',';
getnames=no;
datarow=1;
run;

 

glee217
Calcite | Level 5

Thank you everyone! i worked it out!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 1782 views
  • 2 likes
  • 4 in conversation