BookmarkSubscribeRSS Feed
beaubrunmrmr
Calcite | Level 5

Can someone help with this, 

 

  1. PROC IMPORT OUT=salesByProductByDate DATAFILE= "/home/emilymoore20/EPG194/output/myTestFolder/BSA570v4_Week3_assignment_data.xlsx"
  2. DBMS=xlsx REPLACE;
  3. GETNAMES=YES;
  4. RUN;
  5.  
  6. DATA salesByProductByDate;
  7. SET salesByProductByDate;
  8. year = YEAR(date);
  9. month = YEAR(date);
  10. RUN;
  11.  
  12. PROC REPORT DATA=salesByProductByDate NOWD;
  13. COLUMN ('Sales' year month) product,(sales);
  14. DEFINE year / GROUP STYLE (header)={background=lightgreen};
  15. DEFINE month / GROUP STYLE (header)={background=lightgreen};
  16. DEFINE product / ACROSS ' ' STYLE(header)={background=lightyellow};
  17. DEFINE sales / SUM STYLE(header)={background=lightyellow} FORMAT=DOLLAR15.2;
  18. BREAK AFTER year /SUMMARIZE DOL DUL;
  19. RBREAK AFTER/SUMMARIZE;
  20. COMPUTE AFTER year;
  21. CALL DEFINE('year','style','style=Header{pretext="SubTotal " tagattr="Type:String"}');
  22. ENDCOMP;
  23. COMPUTE AFTER;
  24. CALL DEFINE('year','style','style=Header{pretext="Grand Total " tagattr="Type:String"}');
  25. ENDCOMP;
  26. RUN
  27.  
  28. TITLE '2015 Sales By Product';
  29. PROC SGPLOT DATA=salesByProcudtByDate(WHERE=(year = 2015));
  30. VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster
  31. STAT=sum DATASKIN=gloss;
  32. XAXIS DISPLAY=(nolabel noticks);
  33. YAXIS GRID;
  34. RUN;
  35.  
  36. TITLE '2016 Sales By Product';
  37. PROC SGPLOT DATA=salesByProductByDate(WHERE=(year = 2016));
  38. VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster
  39. STAT=sum DATASKIN=gloss;
  40. XAXIS DISPLAY=(nolabel noticks);
  41. YAXIS GRID;
  42. RUN;
  43.  
  44. TITLE '2017 Sales By Product';
  45. PROC SGPLOT DATA=salesByProductByDate(WHERE=(year = 2017));
  46. VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster
  47. STAT=sum DATASKIN=gloss;
  48. XAXIS DISPLAY=(nolabel noticks);
  49. YAXIS GRID;
  50. RUN;
  51.  
  52. TITLE '2018 Sales By Product';
  53. PROC SGPLOT DATA=salesByProductByDate(WHERE=(year = 2018));
  54. VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster
  55. STAT=sum DATASKIN=gloss;
  56. XAXIS DISPLAY=(nolabel noticks);
  57. YAXIS GRID;
  58. RUN;
5 REPLIES 5
Tom
Super User Tom
Super User
What is the actual question? Did you try to run it? Show the lines from the SAS log.
beaubrunmrmr
Calcite | Level 5

 

 

1.PROC IMPORT OUT=salesByProductByDate DATAFILE=
__
180
71 ! "/home/emilymoore20/EPG194/output/myTestFolder/BSA570v4_Week3_assignment_data.xlsx"
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
72 2.DBMS=xlsx REPLACE
73 3.GETNAMES=YES
74 6.DATA salesByProductByDate
75 7.SET salesByProductByDate
76 8.year = YEAR(date)
77 9.month = YEAR(date)
78 12.PROC REPORT DATA=salesByProductByDate NOWD
79 13.COLUMN ('Sales' year month) product,(sales)
80 14.DEFINE year / GROUP STYLE (header)={background=lightgreen}
81 15.DEFINE month / GROUP STYLE (header)={background=lightgreen}
82 16.DEFINE product / ACROSS ' ' STYLE(header)={background=lightyellow}
83 17.DEFINE sales / SUM STYLE(header)={background=lightyellow} FORMAT=DOLLAR15.2
84 18.BREAK AFTER year /SUMMARIZE DOL DUL
85 19.RBREAK AFTER/SUMMARIZE
86 20.COMPUTE AFTER year
87 21.CALL DEFINE('year','style','style=Header{pretext="SubTotal " tagattr="Type:String"}')
88 22.ENDCOMP
89 23.COMPUTE AFTER
90 24.CALL DEFINE('year','style','style=Header{pretext="Grand Total " tagattr="Type:String"}');
 
91 25.ENDCOMP
___
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
Tom
Super User Tom
Super User
Do not include the line number in your code.
beaubrunmrmr
Calcite | Level 5

what do you mean by line numbers?

Tom
Super User Tom
Super User

The SAS log show line numbers and the text of the line of code.  So in your logs the SAS generate line numbers are the numbers like 71, 72, etc. at the left margin.   But the actual code that you submitted also has numbers at the beginning of the lines.  Numbers like 1,2,3 with periods after them. Remove that stuff and just have the CODE in the program.

The start of your program should look something like this:

PROC IMPORT OUT=salesByProductByDate DATAFILE=
 "/home/emilymoore20/EPG194/output/myTestFolder/BSA570v4_Week3_assignment_data.xlsx"
 DBMS=xlsx REPLACE
;
 GETNAMES=YES;
run;

DATA salesByProductByDate ;
 SET salesByProductByDate ;

etc.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 968 views
  • 0 likes
  • 2 in conversation