BookmarkSubscribeRSS Feed
Costas
Calcite | Level 5
Hi,
I need to build a report about several cognos' cubes (dimensions,
levels measures etc..) from *.mdl files (ascii type) then contain the
structure.
First I import xxxx.mdl file and create variable x, than I exstract
cube infos by scan(x, ....), because all infos are key-substring from
first collumn. when I meet one key value I know the info is on the
next double quoted substring.
For example:

data stat_cube;
infile &infile truncover;
input x $5000.;
retain name datasource;
length datasource $30.;
if x NE '';
test=scan(x,1);
select (test);
when('Name') do;
name=scan(x,2,'"');
valore=name;
datasource='';
end;
when('DataSource') do;
datasource=scan(x,2,'"');
valore=datasource;
end;
when('OrgName') do;
orgname=scan(x,2,'"');
valore=orgname;
end;
when('Dimension') do;
dimension=scan(x,2,'"');
valore=dimension;
end;
when('Root') do;
root=scan(x,2,'"');
valore=root;
end;
when('Levels') do;
levels=scan(x,2,'"');
valore=levels;
end;
when('Measure') do; /*** partial code ***/
measure=scan(x,2,'"');
valore=measure;
end;
otherwise delete;
end;
if test='Name' then DataSource='';
run;

Except for 'Measure', every info is on the row where is the key
value and the uppuer program retrieve all I need.
Sometime for 'Measure' infos are distribuited also on the next rows
and, for some strange reason, cognos could brack it on the successive
row.
The sample below is from an mdl input file:

******* original row data *******
.
.


Measure 2687 "Margini" Storage Default OutPutScale 0 Decimals 0
ReverseSign False
IsCurrency False IsFolder True DrillThrough False EndList

Measure 3041 "Var.% Mrg RC vs RP" Label "Var.% Mrg RC vs RP" ShortName
"Var.% Mrg RC vs RP"
Calc ( "MRG_RAC_RC@2143" - "MRG_RAC_RP@2973" ) / "MRG_RAC_RP@2973"
Timing After_Rollup
"ShortName"='Var.% Mrg RC vs RP' , "Calc"=( "MRG_RAC_RC@2143" -
"MRG_RAC_RP@2973" ) / "MRG_RAC_RP@2973" and "MeasureInfo"="Margine
costi / ricavi finanziari progressivo al mese corrente dell'ann"
"o precedente." DrillThrough False

.
.
*******************************

For first bloc lines the program meet "Measure" and assign his value
at valore=Margini.
For the second I nedd estract also "ShortName" => valore2='Var.% Mrg
RC vs RP' , "Calc" => valore3=( "MRG_RAC_RC@2143" -
"MRG_RAC_RP@2973" ) / "MRG_RAC_RP@2973" and "MeasureInfo"="Margine
costi / ricavi finanziari progressivo al mese corrente dell'anno
precedente."
As you can see on the second bloc info for "MeasureInfo" is splitted
on 2 consecutive lines.
I suppose for read the varius values for "Measure" I must use some do
loop (do while(...)) that scan for all lines relative to the "Measure"
bloc.
Have you any tips about?
Thank you in advance.

Costas
2 REPLIES 2
Costas
Calcite | Level 5
Hi, no tips about?

Costas
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Yes - a looping DO WHILE (); END; code paragraph will do the job quite nicely.

Suggested Google advanced search argument for the SAS.COM support site which has many code samples as well as SAS-hosted DOC:

parse multiple data lines input site:sas.com


Scott Barry
SBBWorks, Inc.

Example reference from search results:
Using SAS® to Parse External Data
Andrew T. Kuligowski, The Nielsen Company
http://www2.sas.com/proceedings/forum2008/190-2008.pdf

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2 replies
  • 789 views
  • 0 likes
  • 2 in conversation