sas2vsta | Generate a ViSta input file from a SAS dataset | sas2vsta |
%sas2vsta(data=new, var=Name Group X1 X2 X3, id=name, about=%str(A sample data set, converted to ViSta));
Observations may be selected by the WHERE= parameter. They appear in the output in their order in the input data set. Sort them first if you want some alternative order.
By default, output is written to a file of the same name as the SAS data set, with the extension '.lsp', in the current SAS directory.
:VARIABLES
list in the case given.
:FREQ t
flag is set. All other variables are treated as Category variables in this
case.
:LABELS
. If two or more variables are given, their values are joined using the SEP= character for each observation.
SEP=%str(,)
.
WHERE=%str(var=value)
if value contains any funny characters.
data foobar (label="My foobar data");for the label to be accessible to this macro.
OUT=FILE, PRINT or STDOUT
[Default: OUT=FILE]
%include macros(sas2vsta); *-- or include in an autocall library; title 'Berkeley Admissions data'; proc format; value admit 1="Admit" 0="Reject" ; value yn 1="+" 0="-" ; value dept 1="A" 2="B" 3="C" 4="D" 5="E" 6="F"; data berkeley (label="Berkeley admissions data"); do dept = 1 to 6; do gender = 'M', 'F'; do admit = 1, 0; input freq @@; output; end; end; end; format dept dept. admit admit.; /* Admit Rej Admit Rej */ cards; 512 313 89 19 353 207 17 8 120 205 202 391 138 279 131 244 53 138 94 299 22 351 24 317 ;To create a file, berkeley.lsp for ViSta, with the table variables ordered Gender, Dept, Admit, and the ID= variables separated by '-', use the following macro call:
%sas2vsta(data=berkeley, var=Gender Dept Admit, freq=Freq, id=Gender Dept Admit, sep=-, about=%str(Berkeley admissions data, from Bickel-etal:75) );The output file, berkeley.lsp looks like this:
(DATA "berkeley" :TITLE "berkeley" :ABOUT "Berkeley admissions data, from Bickel-etal:75" :FREQ t :VARIABLES (QUOTE ( "Gender" "Dept" "Admit" "Freq")) :TYPES (QUOTE ( "Category" "Category" "Category" "Numeric")) :LABELS (QUOTE ( "M-A-Admit" "M-A-Reject" "F-A-Admit" "F-A-Reject" "M-B-Admit" "M-B-Reject" "F-B-Admit" "F-B-Reject" "M-C-Admit" "M-C-Reject" "F-C-Admit" "F-C-Reject" "M-D-Admit" "M-D-Reject" "F-D-Admit" "F-D-Reject" "M-E-Admit" "M-E-Reject" "F-E-Admit" "F-E-Reject" "M-F-Admit" "M-F-Reject" "F-F-Admit" "F-F-Reject" )) :DATA (QUOTE ( "M" "A" "Admit" 512 "M" "A" "Reject" 313 "F" "A" "Admit" 89 "F" "A" "Reject" 19 "M" "B" "Admit" 353 "M" "B" "Reject" 207 "F" "B" "Admit" 17 "F" "B" "Reject" 8 "M" "C" "Admit" 120 "M" "C" "Reject" 205 "F" "C" "Admit" 202 "F" "C" "Reject" 391 "M" "D" "Admit" 138 "M" "D" "Reject" 279 "F" "D" "Admit" 131 "F" "D" "Reject" 244 "M" "E" "Admit" 53 "M" "E" "Reject" 138 "F" "E" "Admit" 94 "F" "E" "Reject" 299 "M" "F" "Admit" 22 "M" "F" "Reject" 351 "F" "F" "Admit" 24 "F" "F" "Reject" 317 )) )