DATA Step, Macro, Functions and more

Problem with SAS Code

Accepted Solution Solved
Reply
Contributor
Posts: 38
Accepted Solution

Problem with SAS Code

I am trying to write the below code, But the date values are missing in the output Dataset. Please Help

 

 

data global_sales;
informat Order_ID$32. Order_Date ddmmyyyy10. Ship_Date ddmmyyyy10. Customer_ID$32. Country$32. Category$32.; 
input Order_ID$ Order_Date Ship_Date Customer_ID$ Segment$ City$ State$ Country$ Category$ Sales Quantity Discount Profit;
format Order_Date date10. Ship_Date date10. Sales dollar7.2 Profit dollar6.2;
cards;
CA_2014_AB10015140_41954 11-11-2014 13-11-2014 AB_100151402 Consumer Oklahoma Oklahoma United_States Technology 221.98 2 0 62.15
;
run;


Accepted Solutions
Solution
‎07-19-2017 02:59 PM
PROC Star
Posts: 7,363

Re: Problem with SAS Code

mmddyyyy isn't a valid informat. Try it with the following:

data global_sales;
informat Order_ID $32. Order_Date ddmmyy10. Ship_Date ddmmyy10. Customer_ID $32. Country $32. Category $32.; 
input Order_ID Order_Date Ship_Date Customer_ID Segment $ City $ State $ Country Category Sales Quantity Discount Profit;
format Order_Date date10. Ship_Date date10. Sales dollar7.2 Profit dollar6.2;
cards;
CA_2014_AB10015140_41954 11-11-2014 13-11-2014 AB_100151402 Consumer Oklahoma Oklahoma United_States Technology 221.98 2 0 62.15
;
run;

Art, CEO, AnalystFinder.com

 

View solution in original post


All Replies
Solution
‎07-19-2017 02:59 PM
PROC Star
Posts: 7,363

Re: Problem with SAS Code

mmddyyyy isn't a valid informat. Try it with the following:

data global_sales;
informat Order_ID $32. Order_Date ddmmyy10. Ship_Date ddmmyy10. Customer_ID $32. Country $32. Category $32.; 
input Order_ID Order_Date Ship_Date Customer_ID Segment $ City $ State $ Country Category Sales Quantity Discount Profit;
format Order_Date date10. Ship_Date date10. Sales dollar7.2 Profit dollar6.2;
cards;
CA_2014_AB10015140_41954 11-11-2014 13-11-2014 AB_100151402 Consumer Oklahoma Oklahoma United_States Technology 221.98 2 0 62.15
;
run;

Art, CEO, AnalystFinder.com

 

Super User
Posts: 17,831

Re: Problem with SAS Code

READ YOUR LOG.

The error is actually pretty clear here, I'm highlighting it in Red. If you fix what it says to fix (too many YY in the format name), check the proper format in the guide it works fine.

https://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n1o9q2mkgoe...

 

 

327 data global_sales;
328 informat Order_ID$32. Order_Date ddmmyyyy10. Ship_Date
-----------
-----------
48 48
328! ddmmyyyy10. Customer_ID$32. Country$32. Category$32.;
ERROR 48-59: The informat DDMMYYYY was not found or could not be
loaded.

329 input Order_ID$ Order_Date Ship_Date Customer_ID$ Segment$
329! City$ State$ Country$ Category$ Sales Quantity Discount
329! Profit;
330 format Order_Date date10. Ship_Date date10. Sales dollar7.2
330! Profit dollar6.2;
331 cards;

Contributor
Posts: 38

Re: Problem with SAS Code

Thanks a lot sir..
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 97 views
  • 0 likes
  • 3 in conversation