BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jonty
Fluorite | Level 6

please help me with this....

i want to put value in variable but its showing error....

reply fast please......

 

code;-

 


proc format lib=Preeti;
value hlthfood
0='No'
1='Yes';
value size
1='Small'
2='Medium'
3='Large';
value org
1='Emphasizes produce'
2='Emphasizes deli'
3='Emphasizes bakery'
4='No emphasis';
value gender
0='Male'
1='Female';
value shopfor
1='Self'
2='Self and spouse'
3='Self and family';
value veg
0='No'
1='Yes';
value style
1='Biweekly' and 'in bulk'
2='Weekly' and 'similar items'
3='Often' and 'whats on sale';
value usecoup
1='No'
2='From newspaper'
3='From mailings'
4='From both';

value carry
0='First period'
1='No coupon'
2='5 percent'
3='15 percent'
4='25 percent';

Value coupval
1='No value'
2='5 percent'
3='15 percent'
4='25 percent'
run;

data preeti.grocery_coupons1;
set Preeti.grocery_coupons;
format preeti.hlthfood hlthfood.;
format size size. ;
format org org. ;
format custid custid. ;
format gender gender. ;
format shopfor shopfor. ;
format veg veg. ;
format style style. ;
format usecoup usecoup. ;
format week week. ;
format seq seq. ;
format carry carry. ;
format coupval coupval. ;
format amtspent amtspent. ;
run;

 

error ;-

 

data preeti.grocery_coupons1;
 
111 set Preeti.grocery_coupons;
112 format preeti.hlthfood hlthfood.;
_________
484
ERROR: Invalid variable specification, preeti.hlthfood. Variable names of the form X.X must be either FIRST.X or LAST.X.
ERROR: The name preeti.hlthfood is not a valid SAS name.
NOTE 484-185: Format HLTHFOOD was not found or could not be loaded.
 
113 format size size. ;
_____
484
NOTE 484-185: Format SIZE was not found or could not be loaded.
 
114 formatorgorg. ;
____
484
NOTE 484-185: Format ORG was not found or could not be loaded.
 
115 formatcustidcustid. ;
_______
484
NOTE 484-185: Format CUSTID was not found or could not be loaded.
 
116 formatgendergender. ;
_______
484
NOTE 484-185: Format GENDER was not found or could not be loaded.
 
117 formatshopforshopfor. ;
________
484
NOTE 484-185: Format SHOPFOR was not found or could not be loaded.
 
118 formatvegveg. ;
____
484
NOTE 484-185: Format VEG was not found or could not be loaded.
 
119 formatstylestyle. ;
______
484
NOTE 484-185: Format STYLE was not found or could not be loaded.
 
120 formatusecoupusecoup. ;
________
484
NOTE 484-185: Format USECOUP was not found or could not be loaded.
 
121 formatweekweek. ;
_____
484
NOTE 484-185: Format WEEK was not found or could not be loaded.
 
122 formatseqseq. ;
____
484
NOTE 484-185: Format SEQ was not found or could not be loaded.
 
123 formatcarrycarry. ;
______
484
NOTE 484-185: Format CARRY was not found or could not be loaded.
 
124 formatcoupvalcoupval. ;
________
484
NOTE 484-185: Format COUPVAL was not found or could not be loaded.
 
125 formatamtspentamtspent. ;
_________
484
NOTE 484-185: Format AMTSPENT was not found or could not be loaded.
 
126 run;
1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

You have a couple of problems with your code. I presume you used a libname statement to specify the Preeti library, but you never used the fmtsearch option to tell SAS that is where your formats exist.

 

Plus, you included that libname in one of your assignment statements, which you should not have done. i.e., you used:

format preeti.hlthfood hlthfood.;

when you should have used:

format hlthfood hlthfood.;

You also specified some formats that you never created, like custid.

 

I didn't correct all of those errors, but the following should be enough for you to correct (i.e., delete the unassigned format declarations):

libname Preeti '/folders/myfolders';
proc format lib=Preeti;
value hlthfood
0='No'
1='Yes';
value size
1='Small'
2='Medium'
3='Large';
value org
1='Emphasizes produce'
2='Emphasizes deli'
3='Emphasizes bakery'
4='No emphasis';
value gender
0='Male'
1='Female';
value shopfor
1='Self'
2='Self and spouse'
3='Self and family';
value veg
0='No'
1='Yes';
value style
1='Biweekly' and 'in bulk'
2='Weekly' and 'similar items'
3='Often' and 'whats on sale';
value usecoup
1='No'
2='From newspaper'
3='From mailings'
4='From both';
value carry
0='First period'
1='No coupon'
2='5 percent'
3='15 percent'
4='25 percent';
Value coupval
1='No value'
2='5 percent'
3='15 percent'
4='25 percent'
run;

data Preeti.grocery_coupons;
  input hlthfood size org custid gender shopfor veg
    style usecoup week seq carry coupval amtspent;
  cards;
0 1 2 3 1 1 1 1 1 1 1 1 1 1
1 2 3 2 0 1 1 1 1 1 1 1 1 1
;

options fmtsearch=(preeti);
data preeti.grocery_coupons1;
set Preeti.grocery_coupons;
format preeti.hlthfood hlthfood.;
format hlthfood hlthfood.;
format size size. ;
format org org. ;
format custid custid. ;
format gender gender. ;
format shopfor shopfor. ;
format veg veg. ;
format style style. ;
format usecoup usecoup. ;
format week week. ;
format seq seq. ;
format carry carry. ;
format coupval coupval. ;
format amtspent amtspent. ;
run;
 

Art, CEO, AnalystFinder.com

 

View solution in original post

1 REPLY 1
art297
Opal | Level 21

You have a couple of problems with your code. I presume you used a libname statement to specify the Preeti library, but you never used the fmtsearch option to tell SAS that is where your formats exist.

 

Plus, you included that libname in one of your assignment statements, which you should not have done. i.e., you used:

format preeti.hlthfood hlthfood.;

when you should have used:

format hlthfood hlthfood.;

You also specified some formats that you never created, like custid.

 

I didn't correct all of those errors, but the following should be enough for you to correct (i.e., delete the unassigned format declarations):

libname Preeti '/folders/myfolders';
proc format lib=Preeti;
value hlthfood
0='No'
1='Yes';
value size
1='Small'
2='Medium'
3='Large';
value org
1='Emphasizes produce'
2='Emphasizes deli'
3='Emphasizes bakery'
4='No emphasis';
value gender
0='Male'
1='Female';
value shopfor
1='Self'
2='Self and spouse'
3='Self and family';
value veg
0='No'
1='Yes';
value style
1='Biweekly' and 'in bulk'
2='Weekly' and 'similar items'
3='Often' and 'whats on sale';
value usecoup
1='No'
2='From newspaper'
3='From mailings'
4='From both';
value carry
0='First period'
1='No coupon'
2='5 percent'
3='15 percent'
4='25 percent';
Value coupval
1='No value'
2='5 percent'
3='15 percent'
4='25 percent'
run;

data Preeti.grocery_coupons;
  input hlthfood size org custid gender shopfor veg
    style usecoup week seq carry coupval amtspent;
  cards;
0 1 2 3 1 1 1 1 1 1 1 1 1 1
1 2 3 2 0 1 1 1 1 1 1 1 1 1
;

options fmtsearch=(preeti);
data preeti.grocery_coupons1;
set Preeti.grocery_coupons;
format preeti.hlthfood hlthfood.;
format hlthfood hlthfood.;
format size size. ;
format org org. ;
format custid custid. ;
format gender gender. ;
format shopfor shopfor. ;
format veg veg. ;
format style style. ;
format usecoup usecoup. ;
format week week. ;
format seq seq. ;
format carry carry. ;
format coupval coupval. ;
format amtspent amtspent. ;
run;
 

Art, CEO, AnalystFinder.com

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 847 views
  • 1 like
  • 2 in conversation