BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
6 REPLIES 6
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
deleted_user
Not applicable
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
RickM
Fluorite | Level 6
SAS names cant start with # but try using a label statement. The variable name wount contain # but it will show up in output.
deleted_user
Not applicable
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.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
deleted_user
Not applicable
Hi Sbb,

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

pharmapk

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 1239 views
  • 0 likes
  • 3 in conversation