* Objective: Print the current date and time in a chart title. * Note: same technique can be use to print date & time as part of the title of a Table. * 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 posted to SPSSX-L on 2001/07/01. * Define a macro which will yield the current date and time. STRING cdate(A17). COMPUTE cdate=STRING($TIME,DATETIME17). 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.