<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Infile varchar issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956766#M373540</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;Bart&lt;/P&gt;
&lt;P&gt;This looks very promising.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The text.txt is created correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when I apply it for my program I get the following error message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: Use of overflow option (MISSOVER, TRUNCOVER, STOPOVER) with binary file (RECFM=N) is dependent on the record length. This &lt;BR /&gt;can produce unexpected results.&lt;BR /&gt;NOTE: UNBUFFERED is the default with RECFM=N.&lt;BR /&gt;NOTE: The infile F is:&lt;BR /&gt;Filename=text.txt,&lt;BR /&gt;URI path=/files/files/12ac4e1a-28f6-45b8-ac14-04bd84c881d0,&lt;BR /&gt;File Identifier=12ac4e1a-28f6-45b8-ac14-04bd84c881d0,&lt;BR /&gt;Content Type=text/plain,Encoding=UTF-8,&lt;BR /&gt;Searchable=false,RECFM=V,LRECL=200000,&lt;BR /&gt;File Size (bytes)=20623,&lt;BR /&gt;Last Modified=21Jan2025:16:27:10,&lt;BR /&gt;Create Time=21Jan2025:15:29:53&lt;BR /&gt;NOTE: Unexpected end of file for binary input.&lt;BR /&gt;NOTE: The data set CASUSER.INFO has 0 observations and 3 variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
cas mySession sessopts=(caslib=casuser timeout=1800 locale="en_US");
caslib _all_ assign;

/* --- Begin Edit --- */
%let BASE_URI=%sysfunc(getoption(servicesbaseurl));

%put &amp;amp;base_uri.;

%let baseurl=https://xxxxxxxxxx;
 
filename folders temp;
proc http
url = "https://xxxxxxxx/folders/folders"
out= folders
oauth_bearer = sas_services;
headers
'Accept'= 'application/vnd.sas.collection+json';
run;
libname folders clear;
libname folders json;
 
%let hostname = https://xxxxxxxxx;
%let endpoint = /folders/folders;
%let path = "/Public/ODAP_REPORTS" ;
%let output = "/in_pdf";
 
/**********************************************************/
/* Retrieve the ID of the folder where the report resides */
/**********************************************************/
filename folders clear;
filename folders temp;
 
proc http
url = "&amp;amp;hostname.&amp;amp;endpoint/@item"
query = ("path"=&amp;amp;path)
out= folders
oauth_bearer = sas_services;
headers
'Accept'= 'application/vnd.sas.content.folder+json';
run;
 
libname folders clear;
libname folders json;
 
/*************************************************/
/* Get a list of objects in that specific folder */
/*************************************************/
/* Identify the endpoint to be used */
proc sql ;
select href, type into :endpoint, :type
from folders.links
where method="GET" and rel = "members";
quit;
 
/* Retrieve the list of objects */
filename memList clear;
filename memList temp;
 
proc http
url = "&amp;amp;hostname.%trim(&amp;amp;endpoint)"
out= memList
oauth_bearer = sas_services;
headers
"Accept"= "%trim(&amp;amp;type)+json";
run;
 
libname memList clear;
libname memList json;
 
/******************************************************/
/* Extract report content (structure) for each report */
/******************************************************/
/* Macro to write the output to a json file */
%sysmacdelete writeJson;
%macro writeJson(name, path);
 
filename outcsv FILESRVC FOLDERPATH='/Users/xxxxxxx@comp.com/My Folder/in_pdf'  FILENAME="_&amp;amp;name..json";
proc json out=outcsv nosastags pretty noscan   ;
export casuser.info;
run;
 
%mend;
 
/* Macro to read the report content and generate the output file */
%sysmacdelete readReportContent;
%macro readReportContent (url, name, path, endpoint, output);
filename f clear;
/* filename f temp; */
filename f FILESRVC FOLDERPATH='/Users/xxxxxxx@comp/My Folder/in_pdf/'  FILENAME="text.txt" lrecl=200000;
 
proc http
url="&amp;amp;url.%trim(&amp;amp;endpoint)/content"
out=f
oauth_bearer=sas_services;
headers
"Accept"="application/vnd.sas.report.content+json";
quit;

%let n=12;

data casuser.info;
length report $128 path $1024 c1-c&amp;amp;n. varchar(32767) content varchar(200000);
infile f lrecl=200000 truncover;
input (c1-c&amp;amp;n.) ($32767.);

content=cats(of c1-c&amp;amp;n.);
array c[*] c1-c&amp;amp;n. content;
report="&amp;amp;name";
path="&amp;amp;path";
drop c1-c&amp;amp;n.;
run;
 
/* data casuser.info; */
/* length report $128 */
/* path $1024 */
/* content varchar(200000); */
/* infile content; */
/* input; */
/* report="&amp;amp;name"; */
/* path="&amp;amp;path"; */
/* content=substrn(_infile_, 1, 200000); */
/* run; */
 
data _null_;
set casuser.info;
where path ne '';
location=tranwrd(path, "/", "_");
mcall=cat('%writeJson(', trim(report), ',', trim(location), ')');
call execute(mcall);
run;
 
/* proc sql; */
/* drop table info; */
/* quit; */
%mend;
 

/* Generate a view containing information to call readReportContent */
proc sql;
create table merged as
select "&amp;amp;hostname" as url,
a.ordinal_items,
a. name,
a.uri,
b.href,
b.type ,
b.method
from memlist.items as a
left join memlist.items_links as b
on a.ordinal_items=b.ordinal_items
having a.contentType="report" and b.rel="getResource";
quit;
 
options mlogic;
 
/* Call readReportContent macro for each report */
data _null_;
length mcall $1024;
set merged(firstobs=1 obs=1);
out=&amp;amp;output;
path=&amp;amp;path;
mcall=cat('%readReportContent(', trim(url), ",", trim(name), ",", trim(path),",", trim(href), ",", trim(out), ')');
call execute(mcall);
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jan 2025 16:45:46 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2025-01-21T16:45:46Z</dc:date>
    <item>
      <title>Infile varchar issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956218#M373407</link>
      <description>&lt;P&gt;My task is to retrieve the json content information from all reports in a specific folder.&lt;/P&gt;
&lt;P&gt;That works quite good but my content variable is limited to 32167 although I try to make it varchar.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I lookup the column properties of the content variable in the casuser.info table it confirms Type: variable character with a length of 800000 (why? I put 200000 in the length statement).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the main issue is that only 32167 characters at maximum carry over to this variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysmacdelete readReportContent;
%macro readReportContent (url, name, path, endpoint, output);
filename content clear;
filename content temp;
 
proc http
url="&amp;amp;url.%trim(&amp;amp;endpoint)/content"
out=content
oauth_bearer=sas_services;
headers
"Accept"="application/vnd.sas.report.content+json";
quit;
 
data casuser.info;
length report $128
path $1024
content varchar(200000);
infile content;
input;
report="&amp;amp;name";
path="&amp;amp;path";
content=substrn(_infile_, 1, 200000);
run;
 
data _null_;
set casuser.info;
where path ne '';
location=tranwrd(path, "/", "_");
mcall=cat('%writeJson(', trim(report), ',', trim(location), ')');
call execute(mcall);
run;
 
/* proc sql; */
/* drop table info; */
/* quit; */
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jan 2025 16:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956218#M373407</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2025-01-15T16:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Infile varchar issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956219#M373408</link>
      <description>&lt;P&gt;I do not see any code in there that is trying to read the JSON file.&lt;/P&gt;
&lt;P&gt;Looks like CAS allows such extreme variables, but if your actual code is using SAS 9.4 code then variables will be limited to 32K bytes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS I suspect that CAS allocated 800K bytes for the variable because it assumed you meant 200K CHARACTERS and there are some UTF-8 characters that require 4 bytes.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 16:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956219#M373408</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-15T16:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Infile varchar issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956740#M373530</link>
      <description>&lt;P&gt;I attach the full code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I had mentioned before, it runs without error and creates a file for each report in the target folder. The text is a json format that allows you to rebuild the Visual Analytics report by loading the pasted json string into a blank report.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BUT it cuts at 32167 bytes which is far to short to describe more sophisticated reports.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cas mySession sessopts=(caslib=casuser timeout=1800 locale="en_US");
caslib _all_ assign;

/* --- Begin Edit --- */
%let BASE_URI=%sysfunc(getoption(servicesbaseurl));

%put &amp;amp;base_uri.;

%let baseurl=https://XXXXXXXXXX;
 
filename folders temp;
proc http
url = "https://XXXXXXXXXX"
out= folders
oauth_bearer = sas_services;
headers
'Accept'= 'application/vnd.sas.collection+json';
run;
libname folders clear;
libname folders json;
 
%let hostname = https://XXXXXXXX;
%let endpoint = /folders/folders;
%let path = "/Public/ODAP_REPORTS" ;
%let output = "/in_pdf";
 
cas mySession sessopts=(caslib=casuser timeout=1800 locale="en_US");
caslib _all_ assign;

/**********************************************************/
/* Retrieve the ID of the folder where the report resides */
/**********************************************************/
filename folders clear;
filename folders temp;
 
proc http
url = "&amp;amp;hostname.&amp;amp;endpoint/@item"
query = ("path"=&amp;amp;path)
out= folders
oauth_bearer = sas_services;
headers
'Accept'= 'application/vnd.sas.content.folder+json';
run;
 
libname folders clear;
libname folders json;
 
/*************************************************/
/* Get a list of objects in that specific folder */
/*************************************************/
/* Identify the endpoint to be used */
proc sql ;
select href, type into :endpoint, :type
from folders.links
where method="GET" and rel = "members";
quit;
 
/* Retrieve the list of objects */
filename memList clear;
filename memList temp;
 
proc http
url = "&amp;amp;hostname.%trim(&amp;amp;endpoint)"
out= memList
oauth_bearer = sas_services;
headers
"Accept"= "%trim(&amp;amp;type)+json";
run;
 
libname memList clear;
libname memList json;
 
/******************************************************/
/* Extract report content (structure) for each report */
/******************************************************/
/* Macro to write the output to a json file */
%sysmacdelete writeJson;
%macro writeJson(name, path);
 
filename outcsv FILESRVC FOLDERPATH='/Users/XXXX@company.com/My Folder/in_pdf'  FILENAME="_&amp;amp;name..json";
proc json out=outcsv nosastags pretty noscan   ;
export casuser.info;
run;
 
%mend;
 
/* Macro to read the report content and generate the output file */
%sysmacdelete readReportContent;
%macro readReportContent (url, name, path, endpoint, output);
filename content clear;
filename content temp;
 
proc http
url="&amp;amp;url.%trim(&amp;amp;endpoint)/content"
out=content
oauth_bearer=sas_services;
headers
"Accept"="application/vnd.sas.report.content+json";
quit;
 
data casuser.info;
length report $128
path $1024
content varchar(200000);
infile content;
input;
report="&amp;amp;name";
path="&amp;amp;path";
content=substrn(_infile_, 1, 200000);
run;
 
data _null_;
set casuser.info;
where path ne '';
location=tranwrd(path, "/", "_");
mcall=cat('%writeJson(', trim(report), ',', trim(location), ')');
call execute(mcall);
run;
 
/* proc sql; */
/* drop table info; */
/* quit; */
%mend;
 

/* Generate a view containing information to call readReportContent */
proc sql;
create table merged as
select "&amp;amp;hostname" as url,
a.ordinal_items,
a. name,
a.uri,
b.href,
b.type ,
b.method
from memlist.items as a
left join memlist.items_links as b
on a.ordinal_items=b.ordinal_items
having a.contentType="report" and b.rel="getResource";
quit;
 
options mlogic;
 
/* Call readReportContent macro for each report */
data _null_;
length mcall $1024;
set merged(firstobs=1);
out=&amp;amp;output;
path=&amp;amp;path;
mcall=cat('%readReportContent(', trim(url), ",", trim(name), ",", trim(path),",", trim(href), ",", trim(out), ')');
call execute(mcall);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jan 2025 12:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956740#M373530</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2025-01-21T12:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Infile varchar issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956746#M373533</link>
      <description>&lt;P&gt;For varchar 200000 is number of characters symbols, 800000 is number of bytes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To read in data try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename f "R:\text.txt" lrecl=200000;

data _null_;
file f;
do x = "B", "C", "D";
do i = 1 to 200000-99;
put "A" @;
end;
put x;
end;
run;


%let n=12;

data _null_1;
length c1-c&amp;amp;n. varchar(32767) d varchar(200000);
infile f lrecl=200000 truncover;
input (c1-c&amp;amp;n.) ($32767.);

d=cats(of c1-c&amp;amp;n.);

array c[*] c1-c&amp;amp;n. d;
do i=1 to dim(c);
y=length(c[i]);
z=lengthm(c[i]); /*in memory length*/
w=lengthn(c[i]); /*real length, 0 for empty string */
n=vname(c[i]);
put n= @10 y @20 z @30 w ;
end;

drop c1-c&amp;amp;n. d;
put "---------------------------";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But remember if you want to save it as SAS7BDAT file it will truncate all char variables to 32767,&lt;/P&gt;
&lt;P&gt;Since you seems to be working on Viya, you could try to save it as SASHDAT (memory drop) format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 14:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956746#M373533</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-01-21T14:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Infile varchar issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956752#M373536</link>
      <description>&lt;P&gt;I cannot figure out what your issue is.&lt;/P&gt;
&lt;P&gt;Did that code not run?&amp;nbsp; If so what errors did you get?&lt;/P&gt;
&lt;P&gt;Did it not produce the right result?&amp;nbsp; How do you know?&lt;/P&gt;
&lt;P&gt;Can't you at least narrow it down to where in the multistep process the issue is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see for example you are making a libref using the JSON engine.&amp;nbsp; Is the issue that the JSON engine cannot read long strings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 14:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956752#M373536</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-21T14:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Infile varchar issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956753#M373537</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code as posted here runs 'successfully' in my environment.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But at some point I lose that part of the string that surpasses 32167 bytes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no error in the log.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 14:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956753#M373537</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2025-01-21T14:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Infile varchar issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956764#M373539</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127222"&gt;@acordes&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I attach the full code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I had mentioned before, it runs without error and creates a file for each report in the target folder. The text is a json format that allows you to rebuild the Visual Analytics report by loading the pasted json string into a blank report.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BUT it cuts at 32167 bytes which is far to short to describe more sophisticated reports.&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which part is the "pasted json string"?&lt;/P&gt;
&lt;P&gt;Which part is the "blank report"?&lt;/P&gt;
&lt;P&gt;Which step is it that is trying to load the "pasted json string" into a "blank report"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should try to figure out if the issue is with your attempt to modify the blank report.&amp;nbsp; Or if the issue is that you did modify the JSON properly but whatever system that is supposed to LOAD it does not accept such long strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember that JSON files are just TEXT.&amp;nbsp; So you can look at them with any text editor.&amp;nbsp; Or even with a simple SAS data step like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "myjsonfilenamehere" recfm=f lrecl=100;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jan 2025 16:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956764#M373539</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-21T16:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Infile varchar issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956766#M373540</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;Bart&lt;/P&gt;
&lt;P&gt;This looks very promising.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The text.txt is created correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when I apply it for my program I get the following error message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: Use of overflow option (MISSOVER, TRUNCOVER, STOPOVER) with binary file (RECFM=N) is dependent on the record length. This &lt;BR /&gt;can produce unexpected results.&lt;BR /&gt;NOTE: UNBUFFERED is the default with RECFM=N.&lt;BR /&gt;NOTE: The infile F is:&lt;BR /&gt;Filename=text.txt,&lt;BR /&gt;URI path=/files/files/12ac4e1a-28f6-45b8-ac14-04bd84c881d0,&lt;BR /&gt;File Identifier=12ac4e1a-28f6-45b8-ac14-04bd84c881d0,&lt;BR /&gt;Content Type=text/plain,Encoding=UTF-8,&lt;BR /&gt;Searchable=false,RECFM=V,LRECL=200000,&lt;BR /&gt;File Size (bytes)=20623,&lt;BR /&gt;Last Modified=21Jan2025:16:27:10,&lt;BR /&gt;Create Time=21Jan2025:15:29:53&lt;BR /&gt;NOTE: Unexpected end of file for binary input.&lt;BR /&gt;NOTE: The data set CASUSER.INFO has 0 observations and 3 variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
cas mySession sessopts=(caslib=casuser timeout=1800 locale="en_US");
caslib _all_ assign;

/* --- Begin Edit --- */
%let BASE_URI=%sysfunc(getoption(servicesbaseurl));

%put &amp;amp;base_uri.;

%let baseurl=https://xxxxxxxxxx;
 
filename folders temp;
proc http
url = "https://xxxxxxxx/folders/folders"
out= folders
oauth_bearer = sas_services;
headers
'Accept'= 'application/vnd.sas.collection+json';
run;
libname folders clear;
libname folders json;
 
%let hostname = https://xxxxxxxxx;
%let endpoint = /folders/folders;
%let path = "/Public/ODAP_REPORTS" ;
%let output = "/in_pdf";
 
/**********************************************************/
/* Retrieve the ID of the folder where the report resides */
/**********************************************************/
filename folders clear;
filename folders temp;
 
proc http
url = "&amp;amp;hostname.&amp;amp;endpoint/@item"
query = ("path"=&amp;amp;path)
out= folders
oauth_bearer = sas_services;
headers
'Accept'= 'application/vnd.sas.content.folder+json';
run;
 
libname folders clear;
libname folders json;
 
/*************************************************/
/* Get a list of objects in that specific folder */
/*************************************************/
/* Identify the endpoint to be used */
proc sql ;
select href, type into :endpoint, :type
from folders.links
where method="GET" and rel = "members";
quit;
 
/* Retrieve the list of objects */
filename memList clear;
filename memList temp;
 
proc http
url = "&amp;amp;hostname.%trim(&amp;amp;endpoint)"
out= memList
oauth_bearer = sas_services;
headers
"Accept"= "%trim(&amp;amp;type)+json";
run;
 
libname memList clear;
libname memList json;
 
/******************************************************/
/* Extract report content (structure) for each report */
/******************************************************/
/* Macro to write the output to a json file */
%sysmacdelete writeJson;
%macro writeJson(name, path);
 
filename outcsv FILESRVC FOLDERPATH='/Users/xxxxxxx@comp.com/My Folder/in_pdf'  FILENAME="_&amp;amp;name..json";
proc json out=outcsv nosastags pretty noscan   ;
export casuser.info;
run;
 
%mend;
 
/* Macro to read the report content and generate the output file */
%sysmacdelete readReportContent;
%macro readReportContent (url, name, path, endpoint, output);
filename f clear;
/* filename f temp; */
filename f FILESRVC FOLDERPATH='/Users/xxxxxxx@comp/My Folder/in_pdf/'  FILENAME="text.txt" lrecl=200000;
 
proc http
url="&amp;amp;url.%trim(&amp;amp;endpoint)/content"
out=f
oauth_bearer=sas_services;
headers
"Accept"="application/vnd.sas.report.content+json";
quit;

%let n=12;

data casuser.info;
length report $128 path $1024 c1-c&amp;amp;n. varchar(32767) content varchar(200000);
infile f lrecl=200000 truncover;
input (c1-c&amp;amp;n.) ($32767.);

content=cats(of c1-c&amp;amp;n.);
array c[*] c1-c&amp;amp;n. content;
report="&amp;amp;name";
path="&amp;amp;path";
drop c1-c&amp;amp;n.;
run;
 
/* data casuser.info; */
/* length report $128 */
/* path $1024 */
/* content varchar(200000); */
/* infile content; */
/* input; */
/* report="&amp;amp;name"; */
/* path="&amp;amp;path"; */
/* content=substrn(_infile_, 1, 200000); */
/* run; */
 
data _null_;
set casuser.info;
where path ne '';
location=tranwrd(path, "/", "_");
mcall=cat('%writeJson(', trim(report), ',', trim(location), ')');
call execute(mcall);
run;
 
/* proc sql; */
/* drop table info; */
/* quit; */
%mend;
 

/* Generate a view containing information to call readReportContent */
proc sql;
create table merged as
select "&amp;amp;hostname" as url,
a.ordinal_items,
a. name,
a.uri,
b.href,
b.type ,
b.method
from memlist.items as a
left join memlist.items_links as b
on a.ordinal_items=b.ordinal_items
having a.contentType="report" and b.rel="getResource";
quit;
 
options mlogic;
 
/* Call readReportContent macro for each report */
data _null_;
length mcall $1024;
set merged(firstobs=1 obs=1);
out=&amp;amp;output;
path=&amp;amp;path;
mcall=cat('%readReportContent(', trim(url), ",", trim(name), ",", trim(path),",", trim(href), ",", trim(out), ')');
call execute(mcall);
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 16:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956766#M373540</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2025-01-21T16:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Infile varchar issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956768#M373541</link>
      <description>&lt;P&gt;looks like RECFM= for the file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;filename f FILESRVC FOLDERPATH='/Users/xxxxxxx@comp/My Folder/in_pdf/'  FILENAME="text.txt" lrecl=200000;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is set to N (binary)&lt;/P&gt;
&lt;P&gt;Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;filename f FILESRVC FOLDERPATH='/Users/xxxxxxx@comp/My Folder/in_pdf/'  FILENAME="text.txt" lrecl=200000 RECFM=V;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 16:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-varchar-issue/m-p/956768#M373541</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-01-21T16:54:17Z</dc:date>
    </item>
  </channel>
</rss>

