BookmarkSubscribeRSS Feed
TommyTea
Fluorite | Level 6

I have a variable that is named Units.  Some of the values the variable takes on are:

 

x10E3/uL   ---------> /* means "times 10000/uL"   It is in E notation here. */

mL/min/1.73

 

As you can see there is a mix of letters and numbers as well as slashes in the 2 observations. How can I tell SAS to read the entire string from a raw data file?

 

I also have another variable named Interval with values such as:

3.4 - 10.8

4.14 - 5.80

 

How can I read these from a raw data file as well?

 

 

 

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16
Consider it as a character variable and it should read the entire string.

Please let me know if it is not clear.

Also let us know how are you importing the raw data file.
Thanks,
Jag
Reeza
Super User

You tell SAS to use a specific delimiter or to read for a specific length. 

 

Given what you've posted we can't really suggest solutions beyond this. Reading a text file can be complicated or easy, it depends on multiple factors and we only have a minimal idea of your issue. 

 

If you'd like further help please post sample data that accurately reflects your situation. 

PGStats
Opal | Level 21

The only difficulty is the dash between the range values. Use pointer control (here +1) to skip it.

 

data abc;
length units $12;
input id rangeLow +1 rangeHigh units :$12.;
datalines;
1 3.4 - 10.8 x10E3/uL
100 4.14 - 5.80 mL/min/1.73
;

proc print; run;
PG
DanielSantos
Barite | Level 11

Hi.

 

To acces the input buffer (whole line of the file) use the automatic variable _INFILE_

 

data WANT;
        infile "<myfile>" lrecl=200;
        input;
        put _INFILE_;
run;

You can also check the following paper by Howard Schreier: http://www.lexjansen.com/nesug/nesug01/cc/cc4018bw.pdf

 

Daniel Santos @ www.cgd.pt

ballardw
Super User

What type of file are you reading from? Most delimited files such as CSV should handle this easily though unmatched quotes might cause other problems. Fixed column has no problem as long as the correct variable type is assigned.

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!

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