DATA Step, Macro, Functions and more

ERROR2

Reply
Contributor
Posts: 50

ERROR2

HI,

THIS IS MY CODE:LIBNAME BEN" C:\Analytixlabs1\5 - Data Exploration (SAS Module 2)";
RUN;
PROC IMPORT OUT= BEN.grocery_coupons1
DATAFILE= "C:\Analytixlabs1\5 - Data Exploration (SAS Module
2)\Grocery_coupons.xls"
DBMS=EXCEL2000 REPLACE;
SHEET="Data$_";
GETNAMES=YES;
RUN;


PROC FORMAT lib=BEN;
VALUE Health_food_store
0=’NO’
1=’YES’;
VALUE Size_of_store
1=’SMALL’
2=’MEDIUM’
3=’LARGE’;
VALUE Store_organization
1=’Emphasizes produce’
2=’Emphasizes delI’
3=’Emphasizes bakery’
4=’No emphasis’;
VALUE Gender
0=’MALE’
1=’FEMALE’;
VALUE Who_shopping_for
1=’SELF’
2=’SELF AND SPOUSE’
3=’SELF AND FAMILY’;
VALUE Vegetarian
0=’NO’
1=’YES’;
VALUE Shopping_style
1=‘Biweekly in bulk’
2=‘Weekly similar items’
3=‘Often whats on sale’;
VALUE Use_coupons
1=‘No’
2=‘From newspaper’
3=‘From mailings’
4=‘From both’;
VALUE Carryover
0=‘First period
1=‘No coupon’
2=‘5 percent’
3=‘15 percent’
4=‘25 percent’;
VALUE Value_of_coupon
1=‘No value’
2=‘5 percent’
3=‘15 percent’
4=‘25 percent’;
RUN;



data BEN.grocery_1;
set Ben.Grocery_coupons;
label storeid="Health food store";
label size= "Size of store";
label hlthfood= "Health food store";
label org= "Store organization";
label custid= "Customer ID";
label gender= "Gender";
label shopfor= "Who shopping for";
label veg= "Vegetarian";
label style= "Shopping style";
label usecoup= "Use coupons";
label week= "Week";
label seq= "Sequence";
label carry= "Carryover";
label coupval= "Value of coupon";
label amtspent= "Amount spent";
format hlthfood Health_food_store.;
format size Size_of_store.;
format org Store_organization.;
format gender Gender.;
format shopfor Who_shopping_for.;
format veg Vegetarian.;
format usecoup Use_coupons.;
format carry Carryover.;
format coupval Value_of_coupon.;
format week Weekformat.;
run;

I AM GEETING AN ERROR

ERROR IS :


174 format veg Vegetarian.;
-----------
48
ERROR 48-59: The format VEGETARIAN was not found or could not be loaded.

175 format usecoup Use_coupons.;
------------
48
ERROR 48-59: The format USE_COUPONS was not found or could not be loaded.

176 format carry Carryover.;
----------
48
ERROR 48-59: The format CARRYOVER was not found or could not be loaded.

177 format coupval Value_of_coupon.;
----------------
48
ERROR 48-59: The format VALUE_OF_COUPON was not found or could not be loaded.

178 format week Weekformat.;
-----------
48
ERROR 48-59: The format WEEKFORMAT was not found or could not be loaded.

179 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set BEN.GROCERY_1 may be incomplete. When this step was stopped there were 0
observations and 16 variables.

Super User
Super User
Posts: 7,970

Re: ERROR2

I have correct several typos in that code. I post the code below.  If you want to change the location of your formats catalog then you need to use:

options fmtsearch

Per the documentation:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000279102.htm

 

libname ben "C:\Analytixlabs1\5 - Data Exploration (SAS Module 2)";

proc import out=ben.grocery_coupons1 datafile="C:\Analytixlabs1\5 - Data Exploration (SAS Module2)\Grocery_coupons.xls"
dbms=excel2000 replace;
sheet="data$_";
getnames=yes;
run;

options fmtsearch=(ben);

proc format library=ben;
value Health_food_store
0='NO'
1='YES';
value Size_of_store
1='SMALL'
2='MEDIUM'
3='LARGE';
value Store_organization
1='Emphasizes produce'
2='Emphasizes delI'
3='Emphasizes bakery'
4='No emphasis';
value Gender
0='MALE'
1='FEMALE';
value Who_shopping_for
1='SELF'
2='SELF AND SPOUSE'
3='SELF AND FAMILY';
value Vegetarian
0='NO'
1='YES';
value Shopping_style
1='Biweekly in bulk'
2='Weekly similar items'
3='Often whats on sale';
value Use_coupons
1='No'
2='From newspaper'
3='From mailings'
4='From both';
value Carryover
0='First period'
1='No coupon'
2='5 percent'
3='15 percent'
4='25 percent';
value Value_of_coupon
1='No value'
2='5 percent'
3='15 percent'
4='25 percent';
run;

data ben.grocery_1;
set ben.grocery_coupons;
label storeid="Health food store"
size= "Size of store"
hlthfood= "Health food store"
org= "Store organization"
custid= "Customer ID"
gender= "Gender"
shopfor= "Who shopping for"
veg= "Vegetarian"
style= "Shopping style"
usecoup= "Use coupons"
week= "Week"
seq= "Sequence"
carry= "Carryover"
coupval= "Value of coupon"
amtspent= "Amount spent";
format hlthfood health_food_store.
size size_of_store.
org store_organization.
gender gender.
shopfor who_shopping_for.
veg vegetarian.
usecoup use_coupons.
carry carryover.
coupval value_of_coupon.
week weekformat.;
run;

 

Contributor
Posts: 50

Re: ERROR2

hi,

its working cool.

but i am only getting a GENDER FORMAT.

I am not getting a whole format in the table .

please tell me what should be the code ?

Super User
Super User
Posts: 7,970

Re: ERROR2

I don't understand what you mean, do you mean the column width is not wide enough tto show the full text, just increase the width of the column?

Super User
Posts: 11,343

Re: ERROR2

Run proc contents on your dataset. All of the format definitions I see are for numeric variables. It may be that due to the vagaries of importing from XLS that some of the variables you expect to be numeric are actually character. In which case the formats aren't going to be applied.

Ask a Question
Discussion stats
  • 4 replies
  • 220 views
  • 0 likes
  • 3 in conversation