Hello, I am new to SAS software. I am trying to get a new data set with 2 variables from a data set from my library. It keeps giving me the error message below. The data set is saved to my library. I am trying to run a new data set to extract only 2 variable IQF and MAXFWT from old data set. Any help would be greatly appreciated.
Thanks!
Text I have inputted into Editor:
data iqf;
set bmi5152 (keep=iqf maxfwt);
run;
proc print data=iqf;
run;
Error message I keep getting:
167 data iqf;
168 set bmi5152 (keep=iqf maxfwt);
ERROR: The variable iqf in the DROP, KEEP, or RENAME list has never been referenced.
ERROR: The variable maxfwt in the DROP, KEEP, or RENAME list has never been referenced.
169 run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.IQF may be incomplete. When this step was stopped there were
0 observations and 0 variables.
WARNING: Data set WORK.IQF was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds
169!
170 proc print data=iqf;
171 run;
NOTE: No observations in data set WORK.IQF.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
Variables IQF and MAXFWT are not in data set bmi5152.
So your code doesn't work.
You can run PROC CONTENTS on data set bmi5152 to see what variables are in there.
They are columns in the dataset.
Obs Id Sex Iqf group pica colic clums irrit maxfwt
1 101 1 70 1 2 2 2 2 72
2 102 1 85 1 2 2 2 2 61
3 103 1 86 1 2 2 2 2 49
@Joliek44 wrote:
They are columns in the dataset.
Obs Id Sex Iqf group pica colic clums irrit maxfwt
1 101 1 70 1 2 2 2 2 72
2 102 1 85 1 2 2 2 2 61
3 103 1 86 1 2 2 2 2 49
When someone says the variable exists and SAS says it doesn't exist, I believe SAS.
So this doesn't prove anything. Only PROC CONTENTS showing these variable names proves your case. Show us PROC CONTENTS on your SAS data set including the part at the top of the PROC CONTENTS output that shows us that it is PROC CONTENTS run on data set bmi5152.
The SAS System |
The CONTENTS Procedure
Data Set Name | BMI515.BMI5152 | Observations | 124 |
Member Type | DATA | Variables | 9 |
Engine | V9 | Indexes | 0 |
Created | 01/20/2020 20:52:06 | Observation Length | 72 |
Last Modified | 01/20/2020 20:52:06 | Deleted Observations | 0 |
Protection |
| Compressed | NO |
Data Set Type |
| Sorted | NO |
Label |
|
|
|
Data Representation | WINDOWS_64 |
|
|
Encoding | wlatin1 Western (Windows) |
|
|
Engine/Host Dependent Information | |
Data Set Page Size | 65536 |
Number of Data Set Pages | 1 |
First Data Page | 1 |
Max Obs per Page | 908 |
Obs in First Data Page | 124 |
Number of Data Set Repairs | 0 |
ExtendObsCounter | YES |
Filename | C:\Users\mcbegay\Documents\ASU SAS Files\DATA\bmi5152.sas7bdat |
Release Created | 9.0401M5 |
Host Created | X64_10PRO |
Owner Name | HEALTH\MCBegay |
File Size | 128KB |
File Size (bytes) | 131072 |
Alphabetic List of Variables and Attributes | |||||
# | Variable | Type | Len | Format | Label |
1 | Id | Num | 8 | BEST8. | Id |
3 | Iqf | Num | 8 | BEST8. | Iqf |
2 | Sex | Num | 8 | BEST8. | Sex |
7 | clums | Num | 8 | BEST8. | clums |
6 | colic | Num | 8 | BEST8. | colic |
4 | group | Num | 8 | BEST8. | group |
8 | irrit | Num | 8 | BEST8. | irrit |
9 | maxfwt | Num | 8 | BEST8. | maxfwt |
5 | pica | Num | 8 | BEST8. | pica |
So there's the problem, the data set is BMI515.BMI5152. Your code is trying to use a different data set, named BMI5152.
So in my library I have BMI515. Inside I have data set BMI5152. It is not in my work library. Am I writing the code wrong?
BMI515.BMI5152 is a data set that does contain the variables you want.
So
set bmi515.bmi5152(keep=iqf maxfwt);
should work.
Got it. i just removed from my bmi515 library and put into my work library and it worked. Thanks for the help.
Monica
Another quick question. Now I have the IQF dataset. How can I sort it by group? There is group 1 and group 2.
I tried using the formula below but does not work.
data iqf;
input group;
cards;
1
;
@Joliek44 wrote:
Another quick question. Now I have the IQF dataset. How can I sort it by group? There is group 1 and group 2.
I tried using the formula below but does not work.
data iqf;
input group;
cards;
1
;
This is too brief a problem description and all I can do is give a very brief answer ... sorting is done by PROC SORT.
@Joliek44 wrote:
Another quick question. Now I have the IQF dataset. How can I sort it by group? There is group 1 and group 2.
I tried using the formula below but does not work.
data iqf;
input group;
cards;
1
;
If you had an IQF dataset you have replaced it by running that data step with a new dataset that has only one variable and only one observation.
If you want to sort a dataset use PROC SORT.
proc sort data=iqf ;
by group;
run;
But that assumes that your dataset actually has a variable named GROUP. Your original dataset had such a variable, but you told SAS not to include GROUP when you created the IGF dataset.
Your proc contents is on
BMI515.BMI5152 |
Your code is using:
bmi5152
Note that you're missing the library reference in your code. It appears you have a different version of the same data set in your work library and one in the BMI515 library.
Only you can know which data set should be used.
Thank you, Yes, I just removed from bmi515 library and into work library and it finally worked. Don't know why it wouldn't run it in my bmi515 library.
Thanks
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.