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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1134 views
  • 0 likes
  • 2 in conversation