PROC IMPORT OUT=salesByProduct DATAFILE= "/home/u36613848/sasuser.v94/ bsa570_v4_wk3_assignment_data.xlsx"
2. DBMS=xlsx REPLACE;
3. GETNAMES=YES;
4. RUN;
5.
6. DATA salesByProduct;
7. SET salesByProduct;
8. year = YEAR(date);
9. month = YEAR(date);
10. RUN;
11.
12. PROC REPORT DATA=salesByProduct 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;
Please show the error you're getting.
You could also reduce the last three procs to one using the BY statement.
@eduar78 wrote:
PROC IMPORT OUT=salesByProduct DATAFILE= "/home/u36613848/sasuser.v94/ bsa570_v4_wk3_assignment_data.xlsx" 2. DBMS=xlsx REPLACE; 3. GETNAMES=YES; 4. RUN; 5. 6. DATA salesByProduct; 7. SET salesByProduct; 8. year = YEAR(date); 9. month = YEAR(date); 10. RUN; 11. 12. PROC REPORT DATA=salesByProduct 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;
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 70 71 1.PROC IMPORT OUT=salesByProductByDate DATAFILE= "/home/u36613848/sasuser.v94/ bsa570_v4_wk3_assignment_data.xlsx" __ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 72 2.DBMS=xlsx REPLACE; 73 3.GETNAMES=YES; __ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 74 4.RUN; __ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 75 5. __ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 76 6.DATA salesByProductByDate; 77 7.SET salesByProductByDate; __ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 78 8.year = YEAR(date); __ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 79 9.month = YEAR(date); __ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 80 10.RUN; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 81 11. ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 82 12.PROC REPORT DATA=salesByProductByDate NOWD; 83 13.COLUMN ('Sales' year month) product,(sales); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 84 14.DEFINE year / GROUP STYLE (header)={background=lightgreen}; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 85 15.DEFINE month / GROUP STYLE (header)={background=lightgreen}; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 86 16.DEFINE product / ACROSS ' ' STYLE(header)={background=lightyellow}; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 87 17.DEFINE sales / SUM STYLE(header)={background=lightyellow} FORMAT=DOLLAR15.2; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 88 18.BREAK AFTER year /SUMMARIZE DOL DUL; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 89 19.RBREAK AFTER/SUMMARIZE; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 90 20.COMPUTE AFTER year; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 91 21.CALL DEFINE('year','style','style=Header{pretext="SubTotal " tagattr="Type:String"}'); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 92 22.ENDCOMP; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 93 23.COMPUTE AFTER; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 94 24.CALL DEFINE('year','style','style=Header{pretext="Grand Total " tagattr="Type:String"}'); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 95 25.ENDCOMP; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 96 26.RUN ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 97 27. 98 28.TITLE '2015 Sales By Product'; 99 29.PROC SGPLOT DATA=salesByProcudtByDate(WHERE=(year = 2015)); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 100 30.VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 101 31.STAT=sum DATASKIN=gloss; 102 32.XAXIS DISPLAY=(nolabel noticks); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 103 33.YAXIS GRID; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 104 34.RUN; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 105 35. ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 106 36.TITLE '2016 Sales By Product'; 107 37.PROC SGPLOT DATA=salesByProductByDate(WHERE=(year = 2016)); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 108 38.VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 109 39.STAT=sum DATASKIN=gloss; 110 40.XAXIS DISPLAY=(nolabel noticks); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 111 41.YAXIS GRID; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 112 42.RUN; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 113 43. ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 114 44.TITLE '2017 Sales By Product'; 115 45.PROC SGPLOT DATA=salesByProductByDate(WHERE=(year = 2017)); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 116 46.VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 117 47.STAT=sum DATASKIN=gloss; 118 48.XAXIS DISPLAY=(nolabel noticks); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 119 49.YAXIS GRID; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 120 50.RUN; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 121 51. ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 122 52.TITLE '2018 Sales By Product'; 123 53.PROC SGPLOT DATA=salesByProductByDate(WHERE=(year = 2018)); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 124 54.VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 125 55.STAT=sum DATASKIN=gloss; 126 56.XAXIS DISPLAY=(nolabel noticks); ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 127 57.YAXIS GRID; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 128 58.RUN; ___ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 129 130 131 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 143These are the errors.
You have pasted line numbers into your program. Remove those.
Thank you much, now is working good. I'm learning the process of SAS!!!
Ok, thanks for the support now I'm receiving this error from this below:
TITLE '2015 Sales By Product';
PROC SGPLOT DATA=salesByProcudtByDate(WHERE=(year = 2015));
VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster
STAT=sum DATASKIN=gloss;
XAXIS DISPLAY=(nolabel noticks);
YAXIS GRID;
RUN;
The log error shows this;
95 TITLE '2015 Sales By Product'; 96 PROC SGPLOT DATA=salesByProcudtByDate(WHERE=(year = 2015)); ERROR: File WORK.SALESBYPROCUDTBYDATE.DATA does not exist. 97 VBAR product / RESPONSE=sales GROUP=month GROUPDISPLAY=cluster ERROR: No data set open to look up variables. ERROR: No data set open to look up variables. ERROR: No data set open to look up variables.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.