*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.
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;
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.
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 :/?
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.
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.
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;
Thank you everyone! i worked it out!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.