Print current date in chart title
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | * Objective: Print the current date in a chart title. * Define dummy data (was given as part of the question) SET SEED=87654321. INPUT PROGRAM. LOOP #I = 1 TO 200. COMPUTE month= TRUNC(UNIFORM(1)*3)+1. COMPUTE year= TRUNC(UNIFORM(1)*3)+1. COMPUTE odse_key= TRUNC(UNIFORM(1)*4)+1. COMPUTE sls_amt= TRUNC(UNIFORM(1)*50)+1. COMPUTE profit= TRUNC(UNIFORM(1)*30)+1. COMPUTE seg_key=TRUNC(UNIFORM(1)*4)+1. COMPUTE dep_key=TRUNC(UNIFORM(1)*4)+1. COMPUTE quart=TRUNC(UNIFORM(1)*16)+1. END CASE. END LOOP. END FILE. END INPUT PROGRAM. EXECUTE. if sls_amt=0 sls_amt=0.01. COMPUTE pmargin =(profit/sls_amt)*100 . EXECUTE . format pmargin (comma). exe. WEIGHT BY sls_amt. SORT CASES BY pmargin (A) . WEIGHT off. * Beginning of solution by rlevesque@videotron.ca. * Define a macro which will yield the current date. STRING cdate(A9). COMPUTE cdate=$DATE. DO IF $casenum=1. WRITE OUTFILE 'temp.sps' /"DEFINE !date()"/cdate/"!ENDDEFINE.". END IF. EXECUTE. * Run the macro. INCLUDE 'temp.sps'. *////////////////////////////////. DEFINE !print (). * The chart title (including the current date) is defined in the next line and used in the next IGRAPH command. !LET !title=!QUOTE(!CONCAT(!EVAL(!date),' SALES BY BRAND BY SEGMENT AMT IN S$K')) IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(month) TYPE = CATEGORICAL /Y = VAR(sls_amt) TYPE = SCALE /PANEL = VAR(dep_key) /COORDINATE = VERTICAL /X1LENGTH = 3.0 /YLENGTH = 3.0 /X2LENGTH = 3.0 /CATORDER VAR(dep_key) (ASCENDING VALUES OMITEMPTY) /CATORDER VAR(month) (ASCENDING VALUES OMITEMPTY) /TITLE =!title /BAR(SUM) KEY=ON SHAPE = RECTANGLE BASELINE = AUTO. EXE. !ENDDEFINE. *////////////////////////////////. !print. |
Related pages
...