BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
daisy6
Quartz | Level 8

Hello SAS guys,

 

I import multiply datasets into SAS. I want my datasets group by monthly and cumulative. If I want my reports generated both monthly and cumulative, how do I code?

Here is the sample codes:

 

%let report=Cumulative;

filename indata pipe "dir &datadir. /b";

data file_list;
length fname$ 256.;
infile indata truncover; /* infile statement for file names */
input fname$ 256.; /* read the file names from the directory */
run;

Proc sql noprint;
create table filename as
select fname from file_list where fname contains ".txt";
select count(DISTINCT fname) into :num_files from filename;
select distinct fname into :filein1 - :filein%left(&num_files) from filename;
create table name as
select compress( scan(fname,1,"."),"&","i" )as fname from filename;
select compress(fname," 12345abced","kis")into :name1 - :name%left(&num_files)
from name;
quit;

%macro fileread;
%do j=1 %to &num_files;
proc import datafile="&datadir.\&&filein&j." out=&&name&j. dbms=csv replace;
getnames=yes;
datarow=2;
guessingrows=32767;
run;
%end;
%mend fileread;
%fileread;

 

/*Now I import three monthly data into SAS. */

%macro outdata;

%if &report="Cumulative" %then %do;

data cdata;

set data10 - data12;

run;

%end;

%else %do;

data cdata;

set data12;

run;

%end;

%mend;

%outdata;

 

But it seems that SAS ignore the condition: &report="Cumulative".

Any help is appreciated.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

you don't need double quotes  here %if &report="Cumulative" 

 

%if &report=Cumulative 

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20

you don't need double quotes  here %if &report="Cumulative" 

 

%if &report=Cumulative 

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
  • 1 reply
  • 632 views
  • 0 likes
  • 2 in conversation