I have a sas data (sas7bdat) of the form below:
1 0 336
1 0 346
0 1 269
0 1 346
1 0 323
1 0 309
0 1 322
0 1 316
1 0 300
1 0 309
How do I use proc format to edit the first two columns?
proc format;
value fxx 1='High' 0='Low';
value fxxxx 1='Yes' 0='No';
run;
libname info 'where data is stored';
data have;
set info.have;
input xx xxxx sbp;
format xx fxx. xxxx fxxxx.;
run;
proc print data=have;
run;
7 libname info 'where data is stored'; NOTE: Libref info was successfully assigned as follows: Engine: V9 Physical Name: where data is stored 8 9 data have; 10 *Use SET statement to set the permanent SAS data set; 11 set info.have; ERROR: File INFO.HAVE.DATA does not exist. 12 input xx xxxx sbp; 13 format xx fxx. xxxx fxxxx.; 14 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.HAVE may be incomplete. When this step was stopped there were 0 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 15 16 *Use PROC PRINT to read the data carefully; 17 proc print data=have; NOTE: Writing HTML Body file: sashtml.htm ERROR: File WORK.HAVE.DATA does not exist. 18 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.58 seconds cpu time 0.09 seconds
I keep getting the same error above. I am trying to import the data from sas and then use proc format to make changes.
Why do I still have column 1 and 2 not formatted? What am I missing?
@JUMMY Your code works
data have;
input var1-var3;
cards;
1 0 336
1 0 346
0 1 269
0 1 346
1 0 323
1 0 309
0 1 322
0 1 316
1 0 300
1 0 309
;
proc format;
value fxx 1='High' 0='Low';
value fxxxx 1='Yes' 0='No';
run;
data have;
set have;
format var1 fxx. var2 fxxxx.;
run;
I think the error is your input statement which i removed
Are there errors in your SAS log? There are when I run this code.
7 libname info 'where data is stored'; NOTE: Libref info was successfully assigned as follows: Engine: V9 Physical Name: where data is stored 8 9 data have; 10 *Use SET statement to set the permanent SAS data set; 11 set info.have; ERROR: File INFO.HAVE.DATA does not exist. 12 input xx xxxx sbp; 13 format xx fxx. xxxx fxxxx.; 14 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.HAVE may be incomplete. When this step was stopped there were 0 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 15 16 *Use PROC PRINT to read the data carefully; 17 proc print data=have; NOTE: Writing HTML Body file: sashtml.htm ERROR: File WORK.HAVE.DATA does not exist. 18 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.58 seconds cpu time 0.09 seconds
I keep getting the same error above. I am trying to import the data from sas and then use proc format to make changes.
@JUMMY wrote:
7 libname info 'where data is stored'; NOTE: Libref info was successfully assigned as follows: Engine: V9 Physical Name: where data is stored 8 9 data have; 10 *Use SET statement to set the permanent SAS data set; 11 set info.have; ERROR: File INFO.HAVE.DATA does not exist. 12 input xx xxxx sbp; 13 format xx fxx. xxxx fxxxx.; 14 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.HAVE may be incomplete. When this step was stopped there were 0 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds
There is no such SAS data set named HAVE in library INFO. So you can't perform this DATA step. As mentioned by @novinosrin , you also can't have an INPUT statement in DATA HAVE
@JUMMY wrote:
@PaigeMiller, I have taken the INPUT statement out. How do I createINFOHAVE in the library? What am I missing?
The same way you create other data sets
data info.have;
/* DATA step code goes here to create the data set */
run;
Of course, the related problem is: you should not be writing code to access a data set (INFO.HAVE) that does not exist.
I strongly agree with @Kurt_Bremser that you need to take some time and learn basic programming concepts via the FREE online video he mentions.
@JUMMY wrote:
7 libname info 'where data is stored'; NOTE: Libref info was successfully assigned as follows: Engine: V9 Physical Name: where data is stored 8 9 data have; 10 *Use SET statement to set the permanent SAS data set; 11 set info.have; ERROR: File INFO.HAVE.DATA does not exist. 12 input xx xxxx sbp; 13 format xx fxx. xxxx fxxxx.; 14 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.HAVE may be incomplete. When this step was stopped there were 0 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 15 16 *Use PROC PRINT to read the data carefully; 17 proc print data=have; NOTE: Writing HTML Body file: sashtml.htm ERROR: File WORK.HAVE.DATA does not exist. 18 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.58 seconds cpu time 0.09 secondsI keep getting the same error above. I am trying to import the data from sas and then use proc format to make changes.
Have you created a LIBRARY named INFO? Yes.
Does the library contain a data set named HAVE??
Syntax of
set info.have;
basically means "read data from a data set named "have" in a library named "info".
If you have not created the library=> Error
if the library does not have a data set with that name=>
And the error will be "does not exist" in either case.
This
11 set info.have; ERROR: File INFO.HAVE.DATA does not exist.
very clearly tells you that you NOT have a dataset called HAVE in library INFO.
The input statement reads from external data sources, not from SAS datasets. It is useless without a corresponding infile statement that defines access to that external data source.
So you do not have any problem with a format, but with the existence of datasets in the first place. From where do you infer that the dataset have should exist, or do you have non-SAS data that needs to be read into a dataset first?
I strongly suggest that you spend the time and work through the (free!) online SAS Programming 1 course, as that will allow you to avoid the simple mistakes you are currently fighting with.
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!
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.