I couldn't resist a quick stab at making this shorter and easier (without
preserving the data, reshaping,etc.) The main short-cut is to use the
extended macro function -piece-. Here's some code to do the basic id
variable plus list a long string. I haven't put in anything to display more
than 2 variables and haven't dealt with value labels (add 2 lines of code),
but here's the basic approach:
program define listlong2
version 8.2
syntax varlist(min=2) [if] [in] [,Indent(integer 10) Length(integer 60)]
gettoken patnr varlist: varlist
gettoken stringvar varlist: varlist
marksample touse, novarlist
markout `touse' `patnr' `stringvar', strok
qui count if `touse'
local start=_N-r(N)+1
local end=_N
local maxpieces=ceil(244/`length')
sort `touse' `patnr'
forval i=`start'(1)`end' {
local id=`patnr'[`i']
local idlen=length("`id'")
local indent=max(`indent',`idlen'+1)
local pad=`indent'-`idlen'
local string=`stringvar'[`i']
forval j=1(1)`maxpieces' {
local part`j': piece `j' `length' of `"`string'"'
if `j'==1 di "`id'" _skip(`pad') `"`part`j'"'
else if `"`part`j''"'!="" di _skip(`indent') `"`part`j'"'
}
}
end
Michael Blasnik
[email protected]
[snip]