Hi Everyone,
I need help with my code execution which i am doing in SAS Studio. This code summarise the size and space information of a specific directory.
Please advise, what should i do?
-Error Log file is attached.
SAS Code:
/*1. Import Directory Usage*/
x du -k /home/deepankeranand0/DSP project > /home/deepankeranand0/DSP project/dirusage.log;
DATA WORK.dirusage;
LENGTH
size_kb 8
path $ 512 ;
LABEL
size_kb = "path size in kb"
path = "path on disc" ;
FORMAT
size_kb BEST9.
path $CHAR96. ;
INFORMAT
size_kb BEST9.
path $CHAR96. ;
INFILE '/sas/data/ad-hoc2/fut_anal/TOOLS/sas_disc_usage/dirusage.log'
DLM='09'x
MISSOVER
DSD ;
INPUT
size_kb : ?? BEST9.
path : $CHAR96. ;
RUN;
/*2. Import File Usage*/
x du -ak /home/deepankeranand0/DSP project > /home/deepankeranand0/DSP project/fileusage.log;
DATA WORK.fileusage;
LENGTH
size_kb 8
path $ 512 ;
LABEL
size_kb = "path size in kb"
path = "path on disc" ;
FORMAT
size_kb BEST9.
path $CHAR96. ;
INFORMAT
size_kb BEST9.
path $CHAR96. ;
INFILE '/home/deepankeranand0/DSP project/fileusage.log'
DLM='09'x
MISSOVER
DSD ;
INPUT
size_kb : ?? BEST9.
path : $CHAR96. ;
RUN;
/*3. DIRECTORITIES BY PATH*/
PROC SQL;
CREATE VIEW WORK.DirSize_ByPath AS
SELECT size_kb,
(size_kb / 1024) as size_mb,
(size_kb / (1024*1024)) as size_gb,
path
FROM WORK.DIRUSAGE
ORDER BY path ASC
;
QUIT;
TITLE;
TITLE1 "Size of Directories on Disc";
FOOTNOTE;
FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), NLTIMAP20.))";
PROC PRINT DATA=WORK.DirSize_ByPath
OBS="Row number"
LABEL
;
VAR path size_gb size_mb;
RUN;
/* -------------------------------------------------------------------
End of task code.
------------------------------------------------------------------- */
RUN; QUIT;
/*4. DIRECTORIES BY SIZE*/
PROC SQL;
CREATE VIEW WORK.DirSize_BySize AS
SELECT size_kb,
(size_kb / 1024) as size_mb,
(size_kb / (1024*1024)) as size_gb,
path
FROM WORK.DIRUSAGE
ORDER BY size_kb DESC
;
QUIT;
TITLE;
TITLE1 "Size of Directories on Disc";
FOOTNOTE;
FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), NLTIMAP20.))";
PROC PRINT DATA=WORK.DirSize_BySize
OBS="Row number"
LABEL
;
VAR path size_gb size_mb;
RUN;
/* -------------------------------------------------------------------
End of task code.
------------------------------------------------------------------- */
RUN; QUIT;
/*5. FILES&DIRECTORIESBYPATH*/
PROC SQL;
CREATE VIEW WORK.DirSize_BySize AS
SELECT size_kb,
(size_kb / 1024) as size_mb,
(size_kb / (1024*1024)) as size_gb,
path
FROM WORK.DIRUSAGE
ORDER BY size_kb DESC
;
QUIT;
TITLE;
TITLE1 "Size of Directories on Disc";
FOOTNOTE;
FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), NLTIMAP20.))";
PROC PRINT DATA=WORK.DirSize_BySize
OBS="Row number"
LABEL
;
VAR path size_gb size_mb;
RUN;
/* -------------------------------------------------------------------
End of task code.
------------------------------------------------------------------- */
RUN; QUIT;
/*6. FILES&DIRECTORIES BY SIZE*/
PROC SQL;
CREATE VIEW WORK.FileSize_BySize AS
SELECT size_kb,
(size_kb / 1024) as size_mb,
(size_kb / (1024*1024)) as size_gb,
path
FROM WORK.FILEUSAGE
ORDER BY size_kb DESC
;
QUIT;
TITLE;
TITLE1 "Size of Directories & Files on Disc";
FOOTNOTE;
FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), NLTIMAP20.))";
PROC PRINT DATA=WORK.FileSize_BySize
OBS="Row number"
LABEL
;
VAR path size_gb size_mb;
RUN;
proc export data = WORK.FileSize_BySize
outfile = '/home/deepankeranand0/DSP project/sas_disc.xls'
dbms = xls;
run;
/* -------------------------------------------------------------------
End of task code.
------------------------------------------------------------------- */
RUN; QUIT;
The error shows that the file isn't found. Can you confirm the file is actually where you think it is?
PS. When posting code/log please only include the relevant portions - the code and log up to the first error.
Are you using SAS Studio that connects to your own SAS Server, SAS Academics On Demand, or SAS University Edition?
Replying to your original post:
First of all, you try to use the x statement, but you obviously work under the -noxcmd system option, so you can't use external commands.
Second, you seem to have blanks in your filenames. Aside from the fact that BLANKS IN FILENAMES ARE A BAD IDEA, you must enclose such names in quotes so that the operating system accepts the blanks as parts of the names, and not as name separators.
Third, you just get a message that a file cannot be found. Log on to the server and check what files are present in the respective directory.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.