3

What syntax do I use to print "hello world" in the output window?

I simply want to specify the text in the syntax and have it appear in the output.

eli-k
  • 10,898
  • 11
  • 40
  • 44
Tikhon
  • 451
  • 1
  • 5
  • 13

4 Answers4

4

You need the title command:

title 'this is my text'.

Note that the title can be up to 256 bytes long.

eli-k
  • 10,898
  • 11
  • 40
  • 44
3

Alternatively, you could use ECHO also. ECHO is useful for debugging macro variable assignements where as TITLE is useful for neat/organised presentation of your tables with intension to perhaps export output results.

Jignesh Sutar
  • 2,909
  • 10
  • 13
3

If you want to write arbitrary text in its own block in the Viewer rather than having it stuck in a log block, use the TEXT extension command (Utilities > Create text output). You can even include html markup in the text.

If you don't have this extension installed, you can install it from the Utilities menu in Statistics 22 or 23 or the Extensions menu in V24.

example:

TEXT "The following output is very important!"
/OUTLINE HEADING="Comment" TITLE="Comment".
JKP
  • 5,419
  • 13
  • 5
2

Outfile here is used in an ambiguous way. The prior two answers (the TITLE and ECHO commands) simply print something to the output window. One additional way to print to the output window is the PRINT command.

DATA LIST FREE / X.
BEGIN DATA
1
2
END DATA.

PRINT /'Hello World'.
EXECUTE.

If you do that set of syntax you will actually see that 'Hello World' is printed twice -- one for each record in the dataset. So one way to only print one line is to wrap it in a DO IF statement and only select the first row of data.

DO IF $casenum=1.
  PRINT /'Hello World'.
END IF.
EXECUTE.

Now how is this any different than the prior two commands? Besides aesthetic looks in the output window, PRINT allows you to save an actual text file of the results via the OUTFILE parameter, which is something neither of the prior two commands allows.

DO IF $casenum=1.
  PRINT OUTFILE='C:\Users\Your Name\Desktop\Hello.txt' /'Hello World'.
END IF.
EXECUTE.
Andy W
  • 5,031
  • 3
  • 25
  • 51