BookmarkSubscribeRSS Feed
prolifious
Obsidian | Level 7

I'm able to run the job and read the sas ouput file, but i can't seem to get the filename csvout '...' to spit out the csv.  my output statement notes 100k observations with 9 variables.    in the filename statement, i've tried lrecl=500, 1000, i didn't include it at all.  I've also tried recfm=v, and leaving it out.  any ideas why this csv is not being generated?  i get the log and the output, with all 100k records, but i cant get the csv.  I've looked through the log and theres nothing noting a probelm with the csv output.

5 REPLIES 5
prolifious
Obsidian | Level 7


libname in1 '/a/b/c' ;

filename csvout '/d/e/list.csv'  lrecl=1000   recfm=v;

DATA TEMP;
SET in1;
KEEP g h;
IF '24FEB17:00:00'DT < STARTIME < '24FEB17:24:00'DT;
IF g IN: (
'x',
);

IF h IN:(
'y',
;

PROC SORT NODUP DATA=TEMP; BY x y;

PROC PRINT NOOBS UNIFORM;

 

 


313 PROC PRINT NOOBS UNIFORM;
NOTE: There were 100010 observations read from the data set WORK.TEMP.
NOTE: The PROCEDURE PRINT printed pages 1-1786.
NOTE: PROCEDURE PRINT used (Total process time)

 

 

There are no errors or anything which speaks to the csv.  I did a search an the only occurance of csv is in my filename statement.  

prolifious
Obsidian | Level 7

please excuse the smiley sad haha

Kurt_Bremser
Super User

First of all, post your code using the "little running man" symbol or the {i}. This preserves formatting and prevents the display of smileys.

libname in1 '/a/b/c' ;

filename csvout '/d/e/list.csv'  lrecl=1000   recfm=v;

DATA TEMP;
SET in1;
KEEP g h;
IF '24FEB17:00:00'DT < STARTIME < '24FEB17:24:00'DT;
IF g IN: (
'x',
);

IF h IN:(
'y',
;

PROC SORT NODUP DATA=TEMP; BY x y;

PROC PRINT NOOBS UNIFORM;

You only define a filename. If you never use the file reference defined here, nothing is ever written to the file.

 

There are other problems with your code, see my comments:

libname in1 '/a/b/c' ;

filename csvout '/d/e/list.csv'  lrecl=1000   recfm=v;

data temp;
set in1; /* this does not read from library in1, but from dataset work.in1! */
keep g h;
if
  '24FEB17:00:00'DT < STARTIME < '24FEB17:24:00'DT
  and g IN ('x')
  and h IN ('y')
;
run;

/* at this point, work.temp contains only variables g and h */

proc sort
  data=TEMP
  nodupkey
;
by x y; /* this won't work, as no variable x or y has been created in one of the previous steps */
run;

data _null_;
set TEMP;
file csvout dlm=',' dsd;
if _n_ = 1 then put 'g;h';
put g h;
run;

 

prolifious
Obsidian | Level 7

Thank you for point out the little running man.  I'll be aware of that for next time.

 

I ended up running this code:

 


ods csv file='/a/b/list.csv';
PROC PRINT data = temp NOOBS UNIFORM;
run;
ods csv close;

 

my csv was output with no problems.  

 

I codejacked that filename csvout from another job.  I need to be better about choosing which statements to use, and learn the differences.

 

Thanks for taking the time to help me, Kurt.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 572 views
  • 0 likes
  • 2 in conversation