BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fuka-japan
Calcite | Level 5

大学の研究のためにSAS Studioを使ってTIMSS2015のSASエクスポートファイルをSASデータファイルに変換したいです。変換するためのプログラムはTIMSS公式で発表されているプログラムを用いました。

(このプログラムはこの投稿に添付してます)

このプログラムのINDIR = 以降にSASエクスポートファイルがあるファイルパスを入力し

OUTDIR=以降に変換したあとのSASデータファイルを収納する場所を指定するファイルパスを入力するとのことだったのでその通り入力したのですが「ERROR: /home/u59515621/ C:\Users\〇〇(私の名前)\OneDrive - 〇〇(大学名).jp\デスクトップ\TIMSS2015_SASData\ATGIRNN1.EXPが存在しません。」と返されてしまいます。

SASを利用したことが初めてであるため、なぜこのようなことになってしまうかがわかりません。

どなたか教えていただけると幸いです。

 

コード:

/******************************************************************************/
/* */
/* SAS Program to Convert SAS Export Files to SAS Data Files */
/* TIMSS 2015 User Guide */
/* */
/******************************************************************************/

OPTIONS NONOTES MPRINT ;

%MACRO DOIT (TYPE = ,
INDIR = ,
OUTDIR = ) ;

LIBNAME OUTDIR "&OUTDIR" ;

* Start of file type processing loop ;

%DO F = 1 %TO %SYSFUNC(COUNTW(&TYPE)) ;
%LET FTYPE = %SCAN(&TYPE,&F) ;

* List of TIMSS Numeracy 2015 countries ;

%LET COUNTRY = BHR IDN IRN JOR KWT MAR ZAF
ABA ;

* Start of country processing loop ;

%LET I = 1 ;
%DO %WHILE(%LENGTH(%SCAN(&COUNTRY,&I))) ;
%LET CTRY = %SCAN(&COUNTRY,&I) ;

PROC CIMPORT FILE="&INDIR.\&FTYPE&CTRY.N1.EXP"
DATA=OUTDIR.&FTYPE&CTRY.N1 ;
RUN ;

* End of country processing loop ;

%LET I = %EVAL(&I + 1) ;
%END ;

* End of file type processing loop ;

%END ;

%MEND DOIT ;

%DOIT (TYPE = ACG ASA ASG ASH ASR AST ATG ,
INDIR = C:\Users\〇〇\OneDrive - 〇〇.jp\デスクトップ\TIMSS2015_SASData ,
OUTDIR = C:\Users\〇〇\OneDrive - 〇〇.jp\デスクトップ\TIMSS SASデータ移行用 ) ;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

From another thread:

 

I worked on a code method that seems to work more reliably than the T15_CONVERT.SAS sample that is provided by TIMSS 2015 site.

/* folder where the TIMSS *.exp files are */
%let in  = /home/myid/folder-with-exp-files;

/* folder to contain the converted data sets*/
%let out = /home/myid/folder-for-datasets;

data filenames;
length fref $8 fname $200;
did = filename(fref, "&in.");
did = dopen(fref);
do i = 1 to dnum(did);
  fname = dread(did,i);
  output;
end;
did = dclose(did);
did = filename(fref);
keep fname;
run;

libname outdir "&out.";

%macro convert(rootname=);
      PROC CIMPORT FILE="&in./&rootname..exp"
                   DATA=OUTDIR.&rootname. ;
      RUN; 
%mend;

data _null_;
 set filenames;
 root = scan(fname,1,".");
 call execute(%nrstr("%convert(rootname="||root||");"));
run;
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

View solution in original post

1 REPLY 1
ChrisHemedinger
Community Manager

From another thread:

 

I worked on a code method that seems to work more reliably than the T15_CONVERT.SAS sample that is provided by TIMSS 2015 site.

/* folder where the TIMSS *.exp files are */
%let in  = /home/myid/folder-with-exp-files;

/* folder to contain the converted data sets*/
%let out = /home/myid/folder-for-datasets;

data filenames;
length fref $8 fname $200;
did = filename(fref, "&in.");
did = dopen(fref);
do i = 1 to dnum(did);
  fname = dread(did,i);
  output;
end;
did = dclose(did);
did = filename(fref);
keep fname;
run;

libname outdir "&out.";

%macro convert(rootname=);
      PROC CIMPORT FILE="&in./&rootname..exp"
                   DATA=OUTDIR.&rootname. ;
      RUN; 
%mend;

data _null_;
 set filenames;
 root = scan(fname,1,".");
 call execute(%nrstr("%convert(rootname="||root||");"));
run;
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Discussion stats
  • 1 reply
  • 719 views
  • 0 likes
  • 2 in conversation