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

Hello Friends

I am trying to run the following code, but I am not error message as  Variable SALESDATE not found in data set WORK.FLOWERSALES.

%LET flowertype = Ginger;
data flowersales;
input customerID $4. @6 SalesDate mmddyy10. @17 Variety $9. quantity 3.;
IF Variety = "&flowertype";
datalines;
240W 02-07-2008 Ginger 120
240W 02-07-2008 Protea 180
356W 02-08-2008 Heliconia 60
356W 02-08-2008 Anthurium 300
188R 02-11-2008 Ginger 24
188R 02-11-2008 Anthurium 24
240W 02-12-2008 Heliconia 48
240W 02-12-2008 Protea 48
356W 02-12-2008 Ginger 240
;
run;
proc print data = flowersales;
format SalesDate WORDDATE18.;
TITLE "Sales of &flowertype";
run;

 

is there any wrong in the code?

Your help is highly appreciated.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

There's a minor issue with your code, but not one that would generate the result you are describing.  Did you read the portion of the log that describes the results of the DATA step?  That would be the most important part.

 

The minor issue is that the informat $9. might read extra characters, including part of the QUANTITY value.  The solution would be to add this statement before the INPUT statement:

 

length variety $ 9;

 

Then the portion of the INPUT statement that reads VARIETY would become:

 

input ... @17 variety $ quantity;

 

My suspicion is that your DATA step contains an error, and an earlier version of FlowerSales is being used (one that does not contain SalesDate).  But you'll have to read the log to be able to tell.

View solution in original post

5 REPLIES 5
Astounding
PROC Star

There's a minor issue with your code, but not one that would generate the result you are describing.  Did you read the portion of the log that describes the results of the DATA step?  That would be the most important part.

 

The minor issue is that the informat $9. might read extra characters, including part of the QUANTITY value.  The solution would be to add this statement before the INPUT statement:

 

length variety $ 9;

 

Then the portion of the INPUT statement that reads VARIETY would become:

 

input ... @17 variety $ quantity;

 

My suspicion is that your DATA step contains an error, and an earlier version of FlowerSales is being used (one that does not contain SalesDate).  But you'll have to read the log to be able to tell.

sas_td2016
Obsidian | Level 7

Thanks for your quick reply.  I really appreciate that.

As you mentioned I modified the code as below;

lenght Variety $9;

input customerID $4. @6 SalesDate mmddyy10. @17 Variety $ @28 quantity 3.;

 

Now it works.  

Thanks a lot 🙂

sas_td2016
Obsidian | Level 7

Hello my friend

I have made little modification on this file as below.  But I am not getting output. Am I doing something wrong here?


data flowersales;
infile 'C:\Users\location\Documents\My SAS Files(32)\democode\tropicalsales.txt' dlm=',';
length Variety $9;
input customerID $ SalesDate mmddyy10.  Variety $  quantity ;
IF Variety = "&flowertype";
run;
proc print data = flowersales;
format SalesDate WORDDATE18.;
TITLE "Sales of &flowertype";
run;

 

data:

240W,02-07-2008,Ginger,120
240W,02-07-2008,Protea,180
356W,02-08-2008,Heliconia,60
356W,02-08-2008,Anthurium,300
188R,02-11-2008,Ginger,24
188R,02-11-2008,Anthurium,24
240W,02-12-2008,Heliconia,48
240W,02-12-2008,Protea,48
356W,02-12-2008,Ginger,240

Astounding
PROC Star

You will need to post the log from running this.  It could be anything ... like are you checking the right place to look for output?  But let's start with examining the log.

Reeza
Super User

Since you've marked this question solved it may be appropriate to start a new question as others won't check this thread. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1411 views
  • 0 likes
  • 3 in conversation