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

Hi, this is fuka-japan.

I need TIMSS2015 data for my study.

So, I want to convert TIMSS 2015 SAS export data files into SAS data files with SAS studio.

However, when I enter the file pass of the export data files, it says " not exist."

I'm not familiar with SAS, so I don't know what to do.

please help me.

 

My code:

/******************************************************************************/
/* */
/* 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 2015 fourth grade countries ;

%IF %UPCASE(%SUBSTR(&FTYPE,1,1)) = A %THEN %DO ;

%LET COUNTRY = AUS BHR BFL BGR CAN CHL TWN HRV CYP CZE
DNK ENG FIN FRA GEO DEU HKG HUN IDN IRN
IRL ITA JPN KAZ KOR KWT LTU MAR NLD NZL
NIR NOR OMN POL PRT QAT RUS SAU SRB SGP
SVK SVN ESP SWE TUR ARE USA
ABA COT CQU NO4 AAD ADU ;

%END ;

* List of TIMSS 2015 eighth grade countries ;

%IF %UPCASE(%SUBSTR(&fTYPE,1,1)) = B %THEN %DO ;

%LET COUNTRY = AUS BHR BWA CAN CHL TWN EGY ENG GEO HKG
HUN IRN IRL ISR ITA JPN JOR KAZ KOR KWT
LBN LTU MYS MLT MAR NZL NOR OMN QAT RUS
SAU SGP SVN ZAF SWE THA TUR ARE USA
ABA COT CQU NO8 AAD ADU ;

%END ;

* 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.M6.EXP"
DATA=OUTDIR.&FTYPE&CTRY.M6 ;
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
BCG BSA BSG BSR BST BTM BTS ,
INDIR = C:\Users\〇〇(it's my name)\OneDrive - △△(it's my university's name).jp\デスクトップ\TIMSS2015_SASData,
OUTDIR = C:\Users\〇〇\OneDrive - △△.jp\デスクトップ\TIMSS SASデータ移行用) ;

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

If you're using SAS Studio you are probably using a SAS environment that is centralized. Maybe SAS OnDemand for Academics?

 

You cannot access your local file system directly. Instead, if you have data to upload (and results to download) you must first place them in a file path that SAS can access. Use the Upload function in SAS Studio to put your data into a place where SAS can reference it. Then use the Download features to copy data to a local folder if needed.

 

The "C:\Users..." paths in this macro call would need to change.

 

%DOIT (TYPE = ACG ASA ASG ASH ASR AST ATG
BCG BSA BSG BSR BST BTM BTS ,
INDIR = C:\Users\〇〇(it's my name)\OneDrive - △△(it's my university's name).jp\デスクトップ\TIMSS2015_SASData,
OUTDIR = C:\Users\〇〇\OneDrive - △△.jp\デスクトップ\TIMSS SASデータ移行用) ;

Update:

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;

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

View solution in original post

1 REPLY 1
ChrisHemedinger
Community Manager

If you're using SAS Studio you are probably using a SAS environment that is centralized. Maybe SAS OnDemand for Academics?

 

You cannot access your local file system directly. Instead, if you have data to upload (and results to download) you must first place them in a file path that SAS can access. Use the Upload function in SAS Studio to put your data into a place where SAS can reference it. Then use the Download features to copy data to a local folder if needed.

 

The "C:\Users..." paths in this macro call would need to change.

 

%DOIT (TYPE = ACG ASA ASG ASH ASR AST ATG
BCG BSA BSG BSR BST BTM BTS ,
INDIR = C:\Users\〇〇(it's my name)\OneDrive - △△(it's my university's name).jp\デスクトップ\TIMSS2015_SASData,
OUTDIR = C:\Users\〇〇\OneDrive - △△.jp\デスクトップ\TIMSS SASデータ移行用) ;

Update:

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;

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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