Help using Base SAS procedures

How to include # symbol in the name line?

Reply
N/A
Posts: 0

How to include # symbol in the name line?

Dear SAS users:

I have a data file with first name line like this
#ID Time Concentration Age Sex Weight etc.

Other lines below are numerical numbers. When I use INFILE statment to input the data file, I found that the "#" is not recognized (so, I used INPUT ID Time Concentration Age Sex Weight etc.), but this did not stop me from further processing the data. The problem is that I would like to keep #ID when I output the post-processed data file. I am hoping get some help about how to either keep # at the first place or add this symbol later.

Thanks

pharmpk
Super Contributor
Super Contributor
Posts: 3,174

Re: How to include # symbol in the name line?

Posted in reply to deleted_user
Share what SAS code you are using, preferably in a SAS-generated log with all code revealed. Also, your SAS version, OS platform, whether running SAS local or remote (connection) is always helpful with getting an accurate and effective reply from forum subscribers.

So, if your point: "I would like to keep #ID when I output the post-processed data file" means that you want to have the first observation contain the data-string found in the header record of your input data, consider that the remaining observations (for the #ID variable) must also be CHARACTER, instead of NUMERIC. This will present challenges with sorting data.

You may want to clarify what your INPUT data looks like and also what you would like to see any OUTPUT (report, SAS dataset) look like. And also clarify why you want the #ID, given that the remaining rows are "numerical numbers".

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: How to include # symbol in the name line?

Hi Sbb:

Thanks for your reply. I am using SAS 9.0 on windows XP system, local.

The input data file is .csv file like this

#ID Time Concentration Age Weight
1 0.1 100 25 70
1 1.0 70 25 70
1 2.0 40 25 70
1 4.0 0 25 70
..........
.........
........
The SAS code I am using is like following:

filename datain
'E:\....csv';
data fulldata;
infile datain DELIMITER=',';
input ID TIME Concentration Age Weight
if ID EQ _blank_ THEN delete;
drop _blank_;
run;
.
.
.
.
.

proc export data=..
outfile= "E:\....csv"
dbms=csv replace;
run;

In the output file, I would like to have "#ID" instead of "ID" in the first line.

Thank you.

pharmpk
Regular Contributor
Posts: 165

Re: How to include # symbol in the name line?

Posted in reply to deleted_user
SAS names cant start with # but try using a label statement. The variable name wount contain # but it will show up in output.
N/A
Posts: 0

Re: How to include # symbol in the name line?

Hi RickM:

Thank you. I tried it. #ID is in the data file in SAS window. But, it is still not in the csv file when I try to export it.
Super Contributor
Super Contributor
Posts: 3,174

Re: How to include # symbol in the name line?

The PROC EXPORT support for SAS label in the header is not until SAS 9.2. You may want to consider the DS2CSV macro for your export needs to a simple CSV, if you must have SAS variable label information in the output's column header.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic/post:
ds2csv site:sas.com
N/A
Posts: 0

Re: How to include # symbol in the name line?

Hi Sbb,

I will check it out.
Thank you so much :-).

pharmapk
Ask a Question
Discussion stats
  • 6 replies
  • 377 views
  • 0 likes
  • 3 in conversation