BookmarkSubscribeRSS Feed
mehak
Calcite | Level 5

In the output i am not able to see the labels . I think there must be a syntax problem 

 

Data _class_s;

set _class_s.Grocery_coupons;
label Storeid =" Store ID "
hlthfood ="Health_food_store"
size = "Size_of_store"
org = "Store_of_organization"
usecoupon = "USE_COUPONS"
week = "Week"
seq = "Sequence"
carry = "Carry_over"
coupval = "Value_of_coupon"
amtspent = "Amount_spent" ;
run;

9 REPLIES 9
art297
Opal | Level 21

Nothing wrong with your code, unless your log is showing an error in that you never assigned the libname _class_s

 

Your code indicates that you are trying to create the file work.class_s, using a file called Grocery_coupons that is located in a libname called _class_s.

 

The following code worked for me:

libname _class_s "/folders/myfolders";
data _class_s.Grocery_coupons;
  input Storeid hlthfood size org usecoupon week seq carry coupval amtspent;
  cards;
1 2 3 4 5 6 7 8 9 10
;

Data _class_s;
set _class_s.Grocery_coupons;
label Storeid =" Store ID "
hlthfood ="Health_food_store"
size = "Size_of_store"
org = "Store_of_organization"
usecoupon = "USE_COUPONS"
week = "Week"
seq = "Sequence"
carry = "Carry_over"
coupval = "Value_of_coupon"
amtspent = "Amount_spent" ;
run;

Art, CEO, AnalystFinder.com

 

mehak
Calcite | Level 5

Sir what if after creating labels i want to assign the values :-

I am getting the error :
VALUE Health_food_store
_____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
104 0='NO'
105 1='YES';

 

code:


data _class_s.Grocery_coupons;
input Storeid hlthfood size org custid gender shopfor veg style usecoupon week seq carry coupval amtspent;
cards;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
;


Data _class_s;set _class_s.Grocery_coupons;
label Storeid =" Store ID "
hlthfood ="Health_food_store"
size = "Size_of_store"
org = "Store_of_organization"
custid = "Customer_ID"
gender ="Gender"
shopfor = "Who_Shopping_For"
veg ="Vegetarian"
style "SHOPPING_STYLE"
usecoupon = "USE_COUPONS"
week = "Week"
seq = "Sequence"
carry = "Carry_over"
coupval = "Value_of_coupon"
amtspent = "Amount_spent" ;
run;


PROC FORMAT lib=_class_s.Grocery_coupons fmtlib;


proc contents data=_class_s.Grocery_coupons;
run;

VALUE Health_food_store
0='NO'
1='YES';

VALUE Size_of_store
1='SMALL'
2='MEDIUM'
3='LARGE';


VALUE Store_of_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;inbulk'
2= 'Weekly;similar_items'
3= 'often;what_on_sale';

VALUE USE_COUPONS
1='NO'
2='From_newspaper'
3='From_mailing'
4='From_both';


VALUE Carryover
0='Firstperiod'
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;


options fmtsearch =(_class_s.Grocery_coupons);

data _class_s;
set _class_s.Grocery_coupons;
format hlthfood Health_food_store. size Size_of_store.
org Store_of_organization. gender Gender. shopfor Who_Shopping_For.
veg Vegetarian. style SHOPPING_STYLE. usecoupon USE_COUPONS.
carry Carryover. coupval Value_of_coupon.;
run;

 

Shmuel
Garnet | Level 18

You broke the PROC FORMAT step inserting proc contents:

PROC FORMAT lib=_class_s.Grocery_coupons fmtlib;


proc contents data=_class_s.Grocery_coupons;
run;

VALUE Health_food_store
0='NO'
1='YES';

 

Move the proc contents at the end of proc format (after RUN; statement);

mehak
Calcite | Level 5

Is this the correct format  to write proper variable and value label  to the variables ???? in this no error is coming . But i want to check the format .

PROC FORMAT lib=_class_s.Grocery_coupons fmtlib;

VALUE Health_food_store 
0='NO' 
1='YES';

VALUE Size_of_store 
1='SMALL' 
2='MEDIUM' 
3='LARGE'; 


VALUE Store_of_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;inbulk' 
2= 'Weekly;similar_items' 
3= 'often;what_on_sale'; 

VALUE USE_COUPONS
1='NO' 
2='From_newspaper' 
3='From_mailing'
4='From_both';


VALUE Carryover
0='Firstperiod'
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; 


options fmtsearch =(_class_s.Grocery_coupons);

data _class_s; 
set _class_s.Grocery_coupons; 
format hlthfood Health_food_store. size Size_of_store. 
org Store_of_organization. gender Gender. shopfor Who_Shopping_For. 
veg Vegetarian. style SHOPPING_STYLE. usecoupon USE_COUPONS. 
carry Carryover. coupval Value_of_coupon.;
run;


proc print data=_class_s;
run;

Kurt_Bremser
Super User

@mehak wrote:

In the output i am not able to see the labels . I think there must be a syntax problem 

 

Data _class_s;

set _class_s.Grocery_coupons;
label Storeid =" Store ID "
hlthfood ="Health_food_store"
size = "Size_of_store"
org = "Store_of_organization"
usecoupon = "USE_COUPONS"
week = "Week"
seq = "Sequence"
carry = "Carry_over"
coupval = "Value_of_coupon"
amtspent = "Amount_spent" ;
run;


Define "output". Procedures like proc print need to be told to use labels, and the viewtables in EG or Base SAS can be configured to either use labels or variable names.

mehak
Calcite | Level 5

Is this the correct format  to write proper variable and value label  to the variables ???? in this no error is coming . But i want to check the format .

PROC FORMAT lib=_class_s.Grocery_coupons fmtlib;

VALUE Health_food_store
0='NO'
1='YES';

VALUE Size_of_store
1='SMALL'
2='MEDIUM'
3='LARGE';


VALUE Store_of_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;inbulk'
2= 'Weekly;similar_items'
3= 'often;what_on_sale';

VALUE USE_COUPONS
1='NO'
2='From_newspaper'
3='From_mailing'
4='From_both';


VALUE Carryover
0='Firstperiod'
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;


options fmtsearch =(_class_s.Grocery_coupons);

data _class_s;
set _class_s.Grocery_coupons;
format hlthfood Health_food_store. size Size_of_store.
org Store_of_organization. gender Gender. shopfor Who_Shopping_For.
veg Vegetarian. style SHOPPING_STYLE. usecoupon USE_COUPONS.
carry Carryover. coupval Value_of_coupon.;
run;


proc print data=_class_s;
run;

art297
Opal | Level 21

You had posted the actual code you ran (including your libname statement and proc import) but, apparently, deleted that post.

 

If you repost it, I'm sure one of us can show you how to correctly run what you're trying to do.

 

Art, CEO, AnalystFinder.com

 

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!

How to Concatenate Values

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.

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
  • 9 replies
  • 1135 views
  • 0 likes
  • 4 in conversation