I have the following program which works on the file ref below but does not seem to work on nref attached which is not output as a continuous file but seems to be wrapping around. Can anyone tell me why and how to correct the problem?
data _null_ ;
infile '/folders/myfolders/bootnew/nREF.CTL' truncover;
/* INPUT CHARACTER FILE*/
input c $1000.;
do i=1 to 2;
myfile='/folders/myfolders/bootnew/nREF' || trim(left(put(i,8.))) || '.ctl';
file dummy filevar=myfile MOD ;
if _n_=2 then do;
if i=1 then do;
amp_loc=index(c,'&');
first_half=substr(c,1,amp_loc-1);
last_half=substr(c,amp_loc+2);
end;
c= trim(first_half) || trim(left(put(i,8.))) || last_half;
end;
put c $;
end;
run;
FILE REF:
$PROBLEM TWO PEAK SEQUENTIAL ZERO AND FIRST ORDER
$DATA ..\TFIT&i.CSV IGNORE=W
$INPUT ID TIME DV DOSE CMT AMT EVID MDV
$SUB ADVAN5 TRANS1
$MODEL
COMP=(1);DOSE1
COMP=(2);DOSE2
COMP=(CENTRAL,DEFOBS);CENTRAL,DEFDOSE)
$PK
KAS= THETA(1)
KAF= THETA(2)
CL = THETA(3)
V3 = THETA(4)
TLAG2= THETA(5)
LOGITT = THETA(6)
TVF1 = 1/(1+EXP(-LOGITT))
F1 = TVF1
S3= V3/1000
F2=1-F1
K23=KAF ;FIRST ORDER MR TO CENTRAL
K13=KAS ;FLOW FROM MR TO CENTRAL
K30=CL/V3 ;ELIMINATION FROM CENTRAL
$ERROR
CP=A(3)/S3
Y=CP +CP*ERR(1) + ERR(2)
$THETA (0.05,0.5) ;1)K0
$THETA (0.05,0.8) ;2)KAS
$THETA (60, 200) ;3)CL L/HR
$THETA (30,100) ;4)V3 L
$THETA (0.1,2) ;5)LAG2 HR
$THETA (-10.0 -0.04 1 ) ;6)LOGIT F1
$OMEGA 0.01 0.1
$EST METH=0 MAXEVAL=9999 PRINT=5
;$COVARIANCE
;$SIM (123456) ONLYSIM SUBPROBLEMS=1
$TABLE ID AMT TIME DV CMT Y DOSE KAF KAS CL V3 TLAG2 LOGITT
ONEHEADER NOPRINT FILE=MOD.FIT
It can be very hard to diagnosis file layout issues when you use a file format other than the original file. A Word document is going to do lots of things when saved that would not occur in a text file.
If your source file is not text, i.e. is a .docx, then that is the first problem.
Lines appearing to wrap are often a symptom of using a UNIX or Apple generated file and reading it on a Windows machine as the line (record) termination is different. Or reading a Windows file on Unix. Hard to say with the attached file as it is not text.
I am not sure that I follow your answer since the ref file contained in the post has similar code just more of it. In both files only line do is worked on by the do loop with the rest to be just output unchanged.
The *.docx was posted since the orginal format was not accepted by the post.
Do you get errors when running the code? Please post the log if so.
If the DOC is a CODE file then do you see a difference between:
data _null_ ;
infile '/folders/myfolders/bootnew/nREF.CTL' truncover;
/* INPUT CHARACTER FILE*/
input c $1000.;
and
$DATA ..\FPLASMA&i.CSV IGNORE=W
$INPUT ID TIME CMT DV DROP AMT=DOSE EVID MDV RATE SEX WT
$SUBR ADVAN13 TRANS1 TOL=6
Note the $ at the start of staments, no semicolon at thend of statements in the second.
I do not beleive that second file is SAS code at all.
If you are attempting to Read the DOC file, or a text version then there may be issues with layout such as no end of line character recognized by your SAS system.
I never got a satisfactory reply so I submitted the question to SAS technical support a week ago and still have not received an answer which is very unusual.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.