Hi Tom, This is the code that I am using, some of the things are sensitive so I have masked them. Basically the input folder from where I am reading the .dat files(comma separated) has 2 different kinds of files, each file has different structure i.e tables/data which is why you'll see the if else statement. I am facing the same issue for both so I had posted just one part of the code. I am not explicitly defining any data type when I am reading from CSV(I believe it will read it as string), I am thinking of defining dtype in read csv, though it should not have been required if the format worked properly while generating the dataset. I am trying to define the format when the output SAS dataset is created, however it doesn't understand the format and defines the format based on the actual data length of the data in tables. I am not getting any errors, if there's a way to display the error logs for df2sd method, the kindly suggest. Dataset looks exactly the same as the data in CSV file, some of the data like column names etc is sensitive so I have masked it. If I remove the format keyword as mentioned in last post then it results in empty dataset in SAS and since I don't know how to get logs for this method I can't view what error is thrown if it is being thrown. Python does not throw any syntax errors both ways which is surprising as this is not what the documentation shows. I am using the below method for printing errors print(my_sas_dataset_inv.HTML) but currently I don't see any errors for that. Code: import pandas as pd import saspy import os saspy.SAScfg sas = saspy.SASsession(cfgfile='C:\\Program Files\\Anaconda3\\lib\\site-packages\\saspy\\sascfg_personal.py') Col_party=['Col1',' Col2', 'Col3', …..] Col_party_inv=['Col4', 'Col5', 'Col6',...] path='C:\\Users\\dummyuser\\Desktop\\trial' files = os.listdir(path) print(files[1]) for file in files: if ".dat" in file: print(file) filename=path+'\\'+file print('filename: '+filename) if "trn_inv" in file: Datekey=file[13:21] print('Datekey: '+Datekey) tablename='tbl1'+Datekey print('tablename: '+tablename) my_dataset_inv = pd.read_csv(filename,names=Col_party_inv,sep='|' , engine='python') my_sas_dataset_inv = sas.df2sd(my_dataset_inv,table=tablename,libref='TEMP',datetimes={'format':{'Col9' : 'date9.'}}, outfmts={'format':{'Col1:'13.', 'Col2':'dollar50.', 'Col3':'dollar35.','Col4':'26.5','Col5':'dollar20.','Col6':'6.', 'Col7':'dollar50.', 'Col8':'dollar50.'}}) my_sas_dataset_inv.head print(my_sas_dataset_inv.HTML) else: Datekey=file[9:17] print('Datekey: '+Datekey) tablename='tbl2'+Datekey print('tablename: '+tablename) my_dataset = pd.read_csv(filename,names=Col_party,sep='|' , engine='python') my_sas_dataset = sas.df2sd(my_dataset,table=tablename,libref='TEMP',datetimes={'format':{'Col9' : 'date9.'}}, outfmts={'format':{'Col1:'13.', 'Col2':'dollar50.', 'Col3':'dollar35.','Col4':'26.5','Col5':'dollar20.','Col6':'6.', 'Col7':'dollar50.', 'Col8':'dollar50.'}}) Output of above python code: filename.dat filename: C:\Users\dummyuser\Desktop\trial\filename.dat Datekey: XXXXX tablename: table1 0 {'LOG': "\x0c10 The SAS System 11:48 Sunday, March 22, 2020\n\n169 ods listing close;ods html5 (id=saspy_internal) file=_tomods1 options(bitmap_mode='inline') device=svg style=HTMLBlue;\n169 ! ods graphics on / outputfmt=png;\nNOTE: Writing HTML5(SASPY_INTERNAL) Body file: _TOMODS1\n170 \n171 \n172 The SAS dataset created.Properties are still the same as posted earlier.
... View more