BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello:

I have a data file like the following stored as a .csv file. I would like to only read the numbers out of it. Right now I am using the following code, it reads in the data file, and I would like to delete every other row (eg,row no. 1, 3, 5, 7, ..), or let's say the rows starting with letters, and only output the numbers. How should I do this?

Thanks in advance



filename datain
'...matrix.csv' LRECL=500;
data matrix;
infile datain DELIMITER=',';
input A $ B $ C $ D $ E $ F $;
run;



TH12,|,TH,5,TH12,|,TH
-7.64E-03,6.06E-01,9.98E-03,2.11E-02,3.96E-01,2.08E+00,1.38E-01

TH15,|,TH,2,TH15,|,TH
4.12E-04,-1.93E-02,-1.74E-03,-1.14E-02,6.39E-01,9.71E-03,2.08E-02

TH15,|,TH10,TH15,|,TH12,TH15
1.75E-01,9.52E-01,9.07E-01,2.17E-03,5.40E-06,-1.05E-04,1.37E-04

OM1213,|,OM0506,OM1213,|,OM0606,OM1213
2.91E-07,-1.48E-05,-3.88E-07,-3.53E-08,-1.07E-07,8.66E-08,-8.50E-08
2 REPLIES 2
data_null__
Jade | Level 19
Use the / pointer control.

[pre]
data matrix;
infile cards dsd;
input / v1-v7;
cards;
TH12,|,TH,5,TH12,|,TH
-7.64E-03,6.06E-01,9.98E-03,2.11E-02,3.96E-01,2.08E+00,1.38E-01
TH15,|,TH,2,TH15,|,TH
4.12E-04,-1.93E-02,-1.74E-03,-1.14E-02,6.39E-01,9.71E-03,2.08E-02
TH15,|,TH10,TH15,|,TH12,TH15
1.75E-01,9.52E-01,9.07E-01,2.17E-03,5.40E-06,-1.05E-04,1.37E-04
OM1213,|,OM0506,OM1213,|,OM0606,OM1213
2.91E-07,-1.48E-05,-3.88E-07,-3.53E-08,-1.07E-07,8.66E-08,-8.50E-08
;;;;
run;
[/pre]
deleted_user
Not applicable
Hello,

you can check if the first character is a digit. the output statement in the syntax is necessary since the return statement contains an implicit OUTPUT statement:

[pre]
data x;
infile datalines dlm=',' truncover;
input @;
if anyalpha(substr(_infile_,1,1)) then return;
input A $ B $ C $ D $ E $ F $;
output;
datalines;
TH12,|,TH,5,TH12,|,TH
-7.64E-03,6.06E-01,9.98E-03,2.11E-02,3.96E-01,2.08E+00,1.38E-01
TH15,|,TH,2,TH15,|,TH
4.12E-04,-1.93E-02,-1.74E-03,-1.14E-02,6.39E-01,9.71E-03,2.08E-02
TH15,|,TH10,TH15,|,TH12,TH15
1.75E-01,9.52E-01,9.07E-01,2.17E-03,5.40E-06,-1.05E-04,1.37E-04
OM1213,|,OM0506,OM1213,|,OM0606,OM1213
2.91E-07,-1.48E-05,-3.88E-07,-3.53E-08,-1.07E-07,8.66E-08,-8.50E-08
;
[/pre]

Marius

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!

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
  • 2 replies
  • 829 views
  • 0 likes
  • 2 in conversation