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-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
  • 5 replies
  • 1093 views
  • 0 likes
  • 3 in conversation