BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
G_I_Jeff
Obsidian | Level 7

Creating a CSV file from ODS and need to remove the first label header record? Is this possible?

ods tagsets.csvnoq file=TAPE rs=none;
proc print data=user.step_two noobs; 
run;                                 
ods tagsets.csvnoq close;

Can I start proc print with obs=2? I've tried (FIRSTOBS=2) but that fails. Is there and ODS or PROC PRINT option that suppresses the label header record?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

So you want a comma delimited text file that does not have a header row?

Why use ODS at all?

data _null_;
   file TAPE dsd;
  set user.step_two;
  put (_all_) (+0);
run;

View solution in original post

7 REPLIES 7
ballardw
Super User

Do you mean that not only you don't want "labels", which that code will not use, but you do not want the variable names either?

 

I think that is going to take a data step.

 

You might try providing a small example data set and how you expect the result to be in the CSV for that data.

 If you do this do NOT paste the csv in main message window as the windows reformat text. Paste the CSV into a text box opened on the forum with the </> icon.

 

If you insist on using tagsets.csvnoq you will also have to provide that tagset as it is not one of the SAS supplied tagsets and we have no way of knowing what is going on inside.

Cynthia_sas
SAS Super FREQ

Hi:
Do you want variable names or do you want just the data? If you switch from PROC PRINT to PROC REPORT, you can generate the data without any headers at all if you use the NOHEADER option as shown below:

Cynthia_sas_0-1628177358104.png

 


Cynthia

Tom
Super User Tom
Super User

So you want a comma delimited text file that does not have a header row?

Why use ODS at all?

data _null_;
   file TAPE dsd;
  set user.step_two;
  put (_all_) (+0);
run;
G_I_Jeff
Obsidian | Level 7

Thanks Tom, this essential gets me what I need.

What is the (+0) on the PUT statement? It seems to be a column or line pointer from what I'm reading on the PUT statement?

Tom
Super User Tom
Super User

You need to use the (varlist)  (fmtlist) syntax of the PUT statement because of the two different meanings of the _ALL_ keyword. With the () the _ALL_ keyword includes all of the variables in the dataset (at least all of them that the compiler has seen already). But without the () the _ALL_ keyword in a PUT statement has a different meaning.  It will print all of the variables, including automatic variables like _N_, with their names in front of them. 

 

But for the (varlist)  (fmtlist) to work you need something non empty in the FMTLIST.  So using +0 to move column zero positions is one option.  You could also include a format modifier like : .  I used to use the : since it was one less character, but the +0 is a little clearer that it is doing nothing.  Plus it won't look like an emoticon. ( 🙂 

G_I_Jeff
Obsidian | Level 7

Tom,

If I now need to add new variables to this data step and order them, how would I exactly do this?

data _null_;                             
 file TAPE dsd;                          
 set user.nfctape;                       
 if size=0 then delete;                  
 if account='' then account='nfcunknown';
 if account=. then account='nfcunknown'; 
 size=size*.001**3;                      
 put (_all_) (+0);                       

The system receiving this file expects to find a identifier/value match on the comma delimited file.

data _null_;                                              
 file TAPE dsd;                                           
 set user.nfctape;                                        
 id='FEEDID';                                             
 sysid='SYSTEMID';                                        
 acntcd='ACCOUNTCODE';                                    
 start='BILLSTARTDATE';                                   
 end='BILLENDDATE';                                       
 rate='ZRMM0012';                                         
 hlq1='DSNACCOUNTCODE1';                                  
 put id ident sysid system acntcd account start start_date
     end end_date rate size hlq1 hlq;                     
 if size=0 then delete;                                   
 if account='' then account='nfcunknown';                 
 if account=. then account='nfcunknown';                  
 size=size*.001**3;                                       
 put (_all_) (+0);                                        
run;                                                      

Would I just order all the new variables I created along with the variables received from the set command in the put (......) statement? 

Tom
Super User Tom
Super User

Yes. You can just list the variables on the PUT statement to control the order they are written.  Since you are no longer using the _ALL_ keyword no need to for the ( ) or the (+0).

put id sysid .... ;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 7 replies
  • 1013 views
  • 3 likes
  • 4 in conversation