BookmarkSubscribeRSS Feed
YW_CA
Calcite | Level 5


I need to export a dataset adding an additional row to the data (csv file). For example, the dataset looks like this

ITEM, PRICE

AB, $50

CD, $40

I want to export the dataset with an additional row before the heading, so it will like:

purchaselist,,

item, price

AB,$50

CD,$40

is there a way to do this?

Thank you.

4 REPLIES 4
art297
Opal | Level 21

Not quite point and click, but you could insert some code like that found at:

Google Groups

Just before where the code has you "put" the variable names, you could have it "put" your initial string.

YW_CA
Calcite | Level 5

Tried this before. The thing is I am running the process in SAS EG from a SAS server, not from local. so when I wrote data _null_, put, it always complained about Insufficient authorization to access

art297
Opal | Level 21

if you run an export where are the files written?  Just indicate the same location (directory) in your file statement.  You have to have write ability somewhere.

Cynthia_sas
SAS Super FREQ

Hi:

  In addition to the other suggestions, instead of doing an EXPORT, using PROC EXPORT or the LIBNAME engine, you could use PROC REPORT and ODS (ODS CSVALL or ODS CSV). In the code below, I show ODS CSVALL (which would also put a SAS title into the output file).;

cynthia

data testdata;

  infile datalines dlm=',';

  input item $ price : comma.;

return;

datalines;

AB,$50

CD,$40

;

run;

title;

ods listing close;

ods csvall file='c:\temp\something.csv';

  proc report data=testdata nowd;

    column ('purchaselist' item price);

    format price dollar3.;

  run;

ods csvall close;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 4 replies
  • 1627 views
  • 1 like
  • 3 in conversation