BookmarkSubscribeRSS Feed
WorkingMan
Calcite | Level 5

Hi. First of all, I have a data step that wants to limit the source(Set statement) to just 10 records. I am WELL AWARE OF 


set library.table (obs=10);

 

However, i am reading HADOOP table where i have "RENAME" and "DBSASTYPE" within set statement. So if this is the case, how do i put in (obs=10) statement?

 

My current code as below:

data OUTPUT1 (drop=year month date time);
					attrib area length=$50 label='Area';
					attrib mnemonic length=$10 label='Mnemonic';
					attrib dp length=$10 label='Voltage';
/*					attrib year length=8 label='Year';*/
/*					attrib month length=$20 label='Month';*/
					attrib transformer length=$10 label='Transformer';
					attrib day length=$20 label='Day';
/*					attrib date length=8 label='Date';*/
/*					attrib time length=8 format=time. label='Time';*/
					attrib datetime length=8 format=datetime. label='Date and Time';
					attrib import_mw length=8 label='MW Import';
					attrib export_mw length=8 label='MW Export';
					attrib import_mvar length=8 label='MVAR Import';
					attrib export_mvar length=8 label='MVAR Export';
					attrib mva length=8 label='MVA';
					attrib power_factor length=8 label='Power Factor';
					attrib data_dttm length=8 format=datetime. label='Data Date and Time';
					set hpsncp.TNBT_METERING_PROFILE 
						  (obs=(10)	(rename=(area=area_ mnemonic=mnemonic_ dp=dp_
										datetime=datetime_ day=day_ transformer=transformer_
										import_mw=import_mw_ export_mw=export_mw_ import_mvar=import_mvar_
										export_mvar=export_mvar_ mva=mva_ power_factor=power_factor_
										filemonthyear=filemonthyear_)
							dbsastype=(area='CHAR(100)' mnemonic='CHAR(100)' dp='CHAR(100)'
							datetime='CHAR(100)' day='CHAR(100)' transformer='CHAR(100)'
							import_mw='CHAR(100)' export_mw='CHAR(100)' import_mvar='CHAR(100)'
							export_mvar='CHAR(100)' mva='CHAR(100)' power_factor='CHAR(100)'
							filemonthyear='CHAR(100)')));


					
run;

 

I do not want to put in where clause or data statement simply because i just want to read 10 records from source without wasting resource to read all records then filter out.

 

Can anyone help me?

1 REPLY 1
Kurt_Bremser
Super User

You need to combine all dataset options into one block:

set hpsncp.TNBT_METERING_PROFILE (
  obs=10
  rename=(
    area=area_ mnemonic=mnemonic_ dp=dp_
    datetime=datetime_ day=day_ transformer=transformer_
    import_mw=import_mw_ export_mw=export_mw_ import_mvar=import_mvar_
    export_mvar=export_mvar_ mva=mva_ power_factor=power_factor_
    filemonthyear=filemonthyear_
  )
  dbsastype=(
    area='CHAR(100)' mnemonic='CHAR(100)' dp='CHAR(100)'
    datetime='CHAR(100)' day='CHAR(100)' transformer='CHAR(100)'
    import_mw='CHAR(100)' export_mw='CHAR(100)' import_mvar='CHAR(100)'
    export_mvar='CHAR(100)' mva='CHAR(100)' power_factor='CHAR(100)'
    filemonthyear='CHAR(100)'
  )
);
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1906 views
  • 0 likes
  • 2 in conversation