BookmarkSubscribeRSS Feed
lcarcano
Calcite | Level 5

Hi everybody,

 

I cannot retrieve the entire values from a CASTable, as they get truncated after 10000 entries when trying to save them as apndas dataframe.

 

i am working with SAS Viya in Python and was trying to access values in the CASTable in order to save them in a pandas dataframe.

When i print infos concerning the table i get (correctly) 21401 rows in the table

 

CASTable(u'my_table', caslib=u'CASUSER(myusername)')
Data columns (total 6 columns):
                 N   Miss    Type
id           21401  False  double
age          21297   True  double
sex_id       21297   True  double
sire_id      21297   True  double
dam_id       21297   True  double
prize_money  21297   True  double

When i try to access the values and print the shape of the values array:

my_table.casTable.values.shape

(10000L, 6L)

So the array gets truncated after 10000 entries .

How can i address that, and get the full numpy array?

 

 

Thanks

 

Luca

3 REPLIES 3
rogerjdeangelis
Barite | Level 11
I know nothing about Viya, but if the CASTable can be converted to a SAS dataset both python and R can read it
library(haven) in R
import SAS&BDAT with sas7bdat in Python?
lcarcano
Calcite | Level 5

Thanks, in the end i managed to solve this problem by exporting the CASTable to SASFrame and then converting the SASFrame to Pandas Dataframe

 

import pandas as pd

my_dataframe =  pd.DataFrame(my_table.to_frame())

KrunalLathiya
Calcite | Level 5

To convert the Pandas object to DataFrame, use to_frame() method. The to_frame() method is used to convert a Series object into a DataFrame. Series is a one-dimensional array with axis labels, which is also defined under the Pandas library.

 

You can export the CASTable to SASFrame and then convert the SASFrame to Pandas Dataframe. Pandas Dataframe.to_numpy() is an inbuilt method that is used to convert a DataFrame to a numpy array.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 1922 views
  • 1 like
  • 3 in conversation