BookmarkSubscribeRSS Feed
daisy6
Quartz | Level 8

Hello,

 

I create a batch file to run winsteps in sas and it doesn't work. I can run my control file directly in winsteps and create output. But when I use SAS command X to run winsteps. It did not provide output file. Here is my code. Could you please check whether my code has problem. Sorry I cannot provide the data.

 

%macro TOT( ankey=,maxitem=, run=);
DATA _NULL_;
set itemid end=eof;
FILE "&dir.\&run._control.txt";
IF _N_ = 1 THEN DO;

PUT
'&INST'/
"TITLE=  run &run."/ /* Change title as needed */
"ITEM1= 11"/
"NI= &maxitem. "/
"NAME1= 1"/
"NAMLEN= 10"/
"XWIDE= 1"/
"CODES= ABCD "/
"TOTALSCORE= Yes"/
"KEY1= &ankey."/
"PVALUE= Y"/
"PTBIS= PTMA"/
/
"ITLEN= 13"/
"IWEIGHT= '&dir.\&run._weight.txt'"/
"DATA= '&dir.\data.txt' "/
"IDFILE= '&dir.\&run._delete.txt' "/
"IAFILE= '&dir.\&run._anchor.txt' "/
"PFILE= '&dir.\&run._persons.txt' "/
"DISFILE= '&dir.\&run._optons.txt' "/
"IFILE= '&dir.\&run._items.txt'"/
/
'*'/
/
"TFILE=* "/
"1.2 "/
"3.1"/
"3.2"/
"14.1"/
"14.3"/
'30'/
"*"/
'&END';
END;
put itemid ;
IF EOF THEN PUT "END NAMES";
RUN;

data _null_;/*change directory and output file name */
file "&dir.\batch.txt";
put "&wspath. BATCH=YES &dir.\&run._CONTROL.TXT &dir.\&run._OUTPUT.TXT";
*put "exit";
run;
/*options xmin noxwait;*/
x "start &dir.\batch.txt";
%mend;
%tot(ankey=&akey.,maxitem=&nitem.,run=1);

 

Thanks a lot!

2 REPLIES 2
Kurt_Bremser
Super User

If you want to know what happens with an external command, run it like this:

filename oscmd pipe "your_command 2>&1";

data _null_;
infile oscmd;
input;
put _infile_;
run;

This will reveal all system output in the SAS log.

daisy6
Quartz | Level 8

KurtBremser, thank you for the reply. I found the problem which because  my DOS system direction is wrong. I adjusted my code and it worked. I appreciate your help. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 862 views
  • 0 likes
  • 2 in conversation