Question: I have a table in SAS which has a variable say X.
I want to know only the range of X, I used PROC UNIVARIATE, but it gives out a lot of other information. 
I have been trying to use RANGE function in the following way, but doesn't yield any result. Please help!

```
DATA DATASET2;
SET DATASET1;
R=RANGE(X);
KEEP R;
RUN;
PROC PRINT DATASET2;

```

RUN;

Answer: 
> 
> I know this code works with O(1):
> 
> 
> `car_value = list(car_dict.values())`
> 
> 
> 

This is incorrect. To form a list from a view you must iterate over all values. This operation will have time complexity of O(n).

In general, creating a list of keys and values is not necessary. Avoid these operations as they are expensive.

Note that `min` can work directly on `dict.items`, which is a view of key-value pairs. This is only advisable if you only have a single car with the minimum value:

```
car, value = min(car_dict.items(), key=lambda x: x[1])  # (fiat, 100)

```

Since dictionaries are not considered ordered (unless you are using Python 3.7), for duplicate minima the result will not be certain. In this case, you can calculate the minimum value and then use a list comprehension:

```
min_val = min(car_dict.values())
min_cars = [car for car, value in car_dict.items() if value == min_val]  # ['fiat']

```

You can also use `next` with a generator expression to extract the first such car:

```
min_car_first = next(car for car, value in car_dict.items() if value == min_val)

```

Of course, in the case of a single car with the minimum value, this will give the same result as the first solution `min(car_dict.items(), ...)`.
well I'm not sure what is the run time of this one but you can try it it works for me : 

```
>>> d = {'mercedes': 200, 'fiat': 100, 'porsche': 300, 'rocketcar': 600}
>>> d.items()
[('mercedes', 200), ('fiat', 100), ('porsche', 300) , ('rocketcar',600)]
>>> # find the minimum by comparing the second element of each tuple
>>> min(d.items(), key=lambda x: x[1]) 
('fiat', 100)

```