BookmarkSubscribeRSS Feed
Sathya3
Obsidian | Level 7

Hi ,

 

I am creating a csv file from sas dataset using ds2csv utility.

I want the column names of this csv file to be lower case. I have given a sample code as well

Can someone please help me with this

data temp;
input NAME $ AGE;
datalines;
ram 21
ravi 34
;
run;

%ds2csv(data=temp,labels=N,runmode=b,csvfile=/out/temp.csv)
1 REPLY 1
Tom
Super User Tom
Super User

You could make a copy of the dataset (or a view that is a copy of the dataset) and either change the names to be lowercase. 

data for_csv;
  retain name age;
  set temp;
run;

or attach labels using the lowercase version of the names and use the labels as the column headers.

 

But since CSV files are trivial to write yourself you could do that.  Which means you can add aline to convert the names to lowercase before writing them.

proc transpose data=temp(obs=0) out=names; 
  var _all_;
run;
data _null_;
  file '/out/temp.csv' dsd ;
  set names;
  _name_=lowcase(_name_;
  put _name_ @;
run;
data _null_;
  set temp;
  file '/out/temp.csv' dsd mod ;
  put (_all_) (+0);
run;

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!

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
  • 1 reply
  • 646 views
  • 0 likes
  • 2 in conversation