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. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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