Hi , I need to export multiple tables into one text file
%macro dist(ind);
proc export data=IBS_count_&ind. (firstobs=1 obs=10)
outfile='/risk/sbs/si/users/recon/crm_3.txt' dbms=tab;
putnames=yes;
run;
%mend;
%dist(CRM_E1);%dist(CRM_E2);%dist(CRM_E3);%dist(CRM_E4);%dist(CRM_E5);%dist(CRM_E6);
When I run the code I just got 1 table . attached output as well . Can you please help in modifying the code . Also how can I align the count variable with its values
Second one first: TAB spacing is very dependent upon the file viewer. Generally the tab will show text at the nearest multiple of some number of characters. If the text in the first column is short one time the tab for the next column appears more to the left, when the text is longer then more to the right. In some cases you may not see any space at all because the first column of text was just the "wrong" length.
I am going to guess that the tab setting of the viewer you used is every 8 characters. Since the first row value of "DATE_E1" is 7 characters long then the "Count" starts in the 9th position as the first available after 8. The following rows have values that are 8 characters. I suspect if you count over you will find the count values start in column 16 or 17 depending.
Now, by multiple sets into a single file do you mean that as each file is added there should be a space or headers or something to indicate the start of the new data? Then Proc Export is not your tool as it is not designed to do that.
If you mean seamlessly see columns of data then append all of the data sets together first then export the large file.
Or manually create such a text file and show us what the result should be.
Second one first: TAB spacing is very dependent upon the file viewer. Generally the tab will show text at the nearest multiple of some number of characters. If the text in the first column is short one time the tab for the next column appears more to the left, when the text is longer then more to the right. In some cases you may not see any space at all because the first column of text was just the "wrong" length.
I am going to guess that the tab setting of the viewer you used is every 8 characters. Since the first row value of "DATE_E1" is 7 characters long then the "Count" starts in the 9th position as the first available after 8. The following rows have values that are 8 characters. I suspect if you count over you will find the count values start in column 16 or 17 depending.
Now, by multiple sets into a single file do you mean that as each file is added there should be a space or headers or something to indicate the start of the new data? Then Proc Export is not your tool as it is not designed to do that.
If you mean seamlessly see columns of data then append all of the data sets together first then export the large file.
Or manually create such a text file and show us what the result should be.
I have created sample dataset and the required format output . I want one .txt file which should have all distributions horizontally . Is there a way to do that
data test;
input date1 date2 date3;
cards;
20201012 20201013 20201014
20201012 20201013 20201014
20201012 20201013 20201014
20171012 20171013 20171014
20201012 20201013 20201014
20171012 20171013 20171014
20171012 20171013 20171014
20171012 20171013 20171014
20171012 20171013 20171014
;
run;
%macro dist(ind);
proc sql;
create table count_&ind. as
select &ind., count (*) as COUNT
from test
group by &ind.
order by 2 desc ;
quit;
%mend;
%dist(date1);%dist(date2);%dist(date3);
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.