BookmarkSubscribeRSS Feed
Antaralib
Obsidian | Level 7

Hi, 

 

I am a beginner. Want to know the informat for a range of values.

 

e.g in the input variable column, I have numbers, then few ranges:

1

2

43

781

226-250

770-821

...

900-921.

 

When I do data cleaning, the last ranges get converted into '.'.

 

 

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

There is no range informat;  SAS is built to hold one data item per variable.

data want;
  infile datalines dlm="-" missover;
  input min max;
datalines;
1
2
43
781
226-250
770-821
;
run;

You can then access the individual data items by variable name, so range is variable min, and variable max.

ballardw
Super User

You may need to desribe a bit more of what you are actually doing or want to do with this variable.

 

If the data is coming to you as shown are you attempting to check membership in a range: is this value in the range of 900-921? Or is the data recorded as "900-921" and you want to assign a specific value? Is the variable supposed to be numeric (something you would do arithmetic with or calculate means and such) or a category indicator (where text is perfectly fine)?

 

If the value is supposed to be numeric you would have to decide on a single value to represent the range. A custom informat could be used to read the data and assign that value, or you could recode the raw value into another variable with the desired value.

 

 

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 882 views
  • 0 likes
  • 3 in conversation