make table as distinct value by column

Reply
Contributor
Posts: 25

make table as distinct value by column

[ Edited ]

 

This macro works very well before I found on the internet.

I used this macro for a long time.

%let TABLE=sashelp.cars;
%let COLUMN=make;
 
proc sql noprint;
/* build a mini program for each value */
/* create a table with valid chars from data value */
select distinct
   cat("DATA out_",compress(&COLUMN.,,'kad'),
   "; set &TABLE.(where=(&COLUMN.='", &COLUMN.,
   "')); run;") into :allsteps separated by ';'
  from &TABLE.;
quit;
/* macro that includes the program we just generated */
%macro runSteps;
&allsteps.;
%mend;
/* and...run the macro when ready */
%runSteps;

I need of two things


1. I want to In addition to adding new condition (where Cylinders=max(Cylinders)) but I could not.

2. Not create SAS data sets, I want to cretae ods html file  and save in my pc.

I would be glad if you help.

 

 

Grand Advisor
Posts: 17,428

Re: make table as distinct value by column

This macro is creating code you can run. 

You can add your condition before the RUN statement. 

 

What at do you mean by HTML output? Do you want a file for each dataset?

Contributor
Posts: 25

Re: make table as distinct value by column

thanks for your reply to Reeza

 

I gave the example of the data set (sashelp.cars).

 

I have the data set with continuous data added  every day or every hours.

So I can not add condition before the RUN statement. Because of dynamic data.

 

This macro make output SAS data set. I want to create type CSV or HTML.

 

thanks..

 

 

 

Grand Advisor
Posts: 17,428

Re: make table as distinct value by column

Is your condition dynamic?

 

You need to explain your problem in more detail. 

Contributor
Posts: 25

Re: make table as distinct value by column

yes,my condition is dynamic which is added date and time whose name is add_date.

 

First of all;
1.Records are added at different times.

2.Records continuously being added to and retained in the archives table.

3.On the same date and time can be added thousands of records for different regions

4.My first condition is the  Maximum Addition time(add_date)

5.Second condition is regions

6.Select the records provide the first and second condition

7.then the selected recording by region and add_date , want to save as CSV or HTML file with name is region_add_date

Region names and add_date are dynamic.

 

best regards..

Contributor
Posts: 25

Re: make table as distinct value by column

Nobody has any idea?

Grand Advisor
Posts: 17,428

Re: make table as distinct value by column

Your requirements have nothing to do with the macro you initially posted. Where does it come in?

 

1.For your first condition a SQL query works fine

2. For second to create a CSV or multiple use either a data step export or proc export. 

 

Which of those do you need help with?

Ask a Question
Discussion stats
  • 6 replies
  • 449 views
  • 0 likes
  • 2 in conversation