6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
16 use vars qw/ $opt_help
25 $opt_debug_subroutine /;
27 ## Configure the command line parsing
28 Getopt::Long::config("auto_abbrev");
30 ## Declare the options
31 my $res = GetOptions("help", # Display help message
41 "debug_subroutine:s" );
45 if($opt_help or $opt_h) {
50 Create_cont_data is a perl script that wraps the rows in a data
51 set with more than 20 columns. Rows that do not end up at
52 exactly 20 will be padded with dummy columns.
56 create_cont_data filename
57 [-idcolumn=column_number]
58 [-cont_column=column_number]
59 [-wrap_column=column_number]
61 [-new_name=new_filename]
65 ./create_cont_data -idc=1 -new=new_wrapped.dta old_big.dta
67 ./create_cont_data -idc=1 -new=new_wrapped.dta -mod=run.mod old_big.dta
72 The number of the column holding the subject identifier. The
76 The number of the column where the CONT data itemn should be
77 placed. The default is to put it as the last item in each row.
80 The number of the columns in each row. The default is 20.
83 The name of a model file. The header as specified in the
84 $INPUT record is used as template for the order and format of
88 The name of the new data set. If no name is given, the result
89 is printed on standard output.
96 ## Check that we do have a model file
97 if ( scalar(@ARGV) < 1 ) {
98 print "A data file must be specified. Use 'create_cont_data -h' for help.\n";
102 ui
-> category
( 'data' );
104 debug
-> level
( $opt_debug );
105 debug
-> package( $opt_debug_package );
106 debug
-> subroutine
( $opt_debug_subroutine );
108 my ( $mod, @model_header );
109 if ( defined $opt_model ) {
110 $mod = model
-> new
( filename
=> $opt_model );
111 @model_header = @
{$mod -> problems
-> [0] -> header
};
114 my $data = data
-> new
( filename
=> $ARGV[0],
115 model_header
=> \
@model_header,
116 idcolumn
=> $opt_idcolumn );
118 if ( defined $opt_new_name ) {
119 open( NEW
, ">$opt_new_name" );
120 my ($data_ref, $prim_ref, $sec_ref ) = $data ->
121 format_data
( wrap
=> 1,
122 cont_column
=> $opt_cont_column,
123 wrap_column
=> $opt_wrap_column );
124 print NEW @
{$data_ref};
127 my ($data_ref, $prim_ref, $sec_ref ) = $data ->
128 format_data
( wrap
=> 1,
129 cont_column
=> $opt_cont_column,
130 wrap_column
=> $opt_wrap_column );